0

I need to call a js-function with many parameters. Assume,

function Create()
{
    var a = $("#a").val();
    var b = $("#b").val();
    var c = $("#c").val();
    var d = $("#d").val();
    var e = $("#e").val();
    var f = $("#f").val();

    var arraydata = [a, b, c, d, e, f];

    //: 1. calling js-function with direct parameters
    var IsError = Validate_param(a, b, c, d, e, f); 

    //: 2. calling js-function with array
    var IsError = Validate_array(arraydata); 

    if (IsError == 0)
    {
          //: Do some operations...
    }
}

The validation js-function's are,

function Validate_param(a, b, c, d, e, f)
{
      alert("The value of a : "+ a);
}

function Validate_array(arraydata)
{
      alert("The value of a : "+ arraydata[0]);
}

My doubt is which is best way to call a js-function with many parameters. Here, i wrote 2 js-functions for validations. Which function will give better performance, Validate_param() or Validate_array() ?

Thanks in advance..

1
  • 1
    I think that, for only a few parameters, the difference would be negligible. Commented Jun 20, 2013 at 10:19

1 Answer 1

2

You don't need the array overload as you can already access passed arguments from the arguments array.

Anyway, you shouldn't worry about a small potential performance difference.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply.. So, the difference of calling this 2 function performance are small potential only.. right ? & where can i test this type of js function performance through online ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.