1

I have the following problem where I have function with parameters and I have an array of the values associated with the parameters.

var myFunction = function(argument_0, argument_1 ) {
//do stuff
}
var arguments = new Array();
arguments[0] = "value0";
arguments[1] = "value1";

How would I go about passing that array in the same format to the function?

1

1 Answer 1

7

You can use .apply()

myFunction.apply(null, arguments);
Sign up to request clarification or add additional context in comments.

1 Comment

spot on. Thanks very much.

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.