I am trying to concat an arguments
object with another array, and I wrote code like this:
[].concat.call(arguments, newArray)
But it returns [ [object Arguments], ... ]
, that is exactly not what I want. I googled and found some explanations for why I could do this through slice method: How can I convert the "arguments" object to an array in JavaScript?
But after looked up the spec, I found the same definition on concat method:
NOTE The
concat
function is intentionally generic; it does not require that its this value be an Array object. Therefore it can be transferred to other kinds of objects for use as a method. Whether theconcat
function can be applied successfully to a host object is implementation-dependent.
The spec is here: http://es5.github.io/#x15.4.4.4
So now I am confusing why I can't convert the arguments
object to an array through the concat
method.