There is a way to pass array elements as separate arguments in Node.js #48

FinesseRus opened this Issue Nov 28, 2015 · 3 comments


None yet

4 participants

var a = [1, 2, 3];
add3.apply(window, a);

I don't think node has a global window object. I get "ReferenceError: window is not defined" when I try it.


global works also.

Also try using this instead.

var a = [1, 2, 3];
add3.apply(this, a);

If you are nesting the functions you could set window=this or global=this at the beginning of the file


As this function doesn't need a context call, you can just:

add3.apply(null, a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment