Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Finesse opened this issue Nov 28, 2015 · 3 comments
Open

Comments

@Finesse
Copy link

Finesse commented Nov 28, 2015

var a = [1, 2, 3];
add3.apply(window, a);
@clarkgrubb
Copy link
Owner

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

@7fe
Copy link

7fe commented Apr 4, 2016

@clarkgrubb
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

@hbarcelos
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants