How to unpack a list inside Javascript

wiccy's icon

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,

Christopher Dobrian's icon

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]+",");
    }
}