Take the 2-minute tour ×

This question already has an answer here:

I'm confused with Node.js function arguments object.

Suppose i have following code:

function x() {
  return arguments;

console.log(x(1, 2, 3));

In chrome developer tools it returns as an Array:

[1, 2, 3]

But i got different result in node.js:


How come?

share|improve this question



3 Answers 3

up vote 5 down vote accepted


Other objects like this are NodeList for example.

share|improve this answer
Ok @Frits van Campen. I got it. I run this to check it's type: console.log(Object.prototype.toString.call(x())); Both return same result: [object Arguments] –  user1725316 Mar 29 '13 at 15:10
Cool, I didn't know you could do that =) –  Halcyon Mar 29 '13 at 15:13
very funny frits. LoL –  user1725316 Mar 29 '13 at 15:21



var args = Array.prototype.slice.call(arguments, 0);
share|improve this answer
This saved me doing work in node, where I assumed that arguments was an array. Silly js developer. Browsers are for kids. "intern-runner": { command: function(){ var cmdArgs = ""; var args = Array.prototype.slice.call(arguments, 0); if(args){ cmdArgs = args.join(" "); } return 'node node_modules/intern/bin/intern-runner config=app/intern-config ' + cmdArgs; } }, –  httpete Sep 25 at 13:21


share|improve this answer