Forums > Javascript

How to unpack a list inside Javascript

November 27, 2013 | 2:18 pm

Hi.

Say, the js object take one inlet. But the input is a list of two numbers. And I want the js to unpack the list inside the function and make some calculation. How can I do it?

If not, how to do the same job but having two inlets with two separate number rather than one.

Thanks,


November 27, 2013 | 4:34 pm

Make a list() function. The items in the incoming list will be in an array named ‘arguments’ in that function.

function list()
{
for (i=0; i < arguments.length; i++)
{
post("item ", i+1, "is", arguments[i]+",");
}
}


Viewing 2 posts - 1 through 2 (of 2 total)