0

I have a simple function with 2 parameters:

function foo(a,b)
{
    return a + b
}

then I can call the function with arguments:

c = foo(10,20)

Now if I assemble the argument values in an array,

var args = []
args.push(100)
args.push(200)

How can I call the function by passing in the array?

d = foo(args.WHAT_IS_THIS_FUNCTION()) 

for example,

d = foo(args.join()) 

is equivalent to

d = foo("100,200") 

which is not what I wanted.

The question is simple: how can I call function "foo" by feeding an array as argument(s)?

milesma
  • 1,561
  • 1
  • 15
  • 37

0 Answers0