The difference is that arguments
is an "array-like" object, not an array.
You can convert the arguments
object to a real array by slicing it, like so
Array.prototype.slice.call(arguments, 0);
This gives you an array, with array properties like forEach
, pop
etc. which objects like arguments
don't have (except length, which arguments
do have).
It is generally (almost) never a good idea to slice the arguments
object, MDN gives the warning
You should not slice on arguments because it prevents optimizations in
JavaScript engines (V8 for example). Instead, try constructing a new
array by iterating through the arguments object.
Also there should be no real need to pass arguments to a function, only to return them.