Why does applying the slice method to the javascript arguments value as follows Array.prototype.slice.call(arguments) convert it to an array? If slice is used on arrays, and arguments is not an array, then how does this work? Is it just a special case when slice is applied to arguments?
Why does applying the slice method to the javascript arguments value as follows Array.prototype.slice.call(arguments)
Share
From the EcmaScript specification on
Array.prototype.slice:And so,
sliceworks on every object that has alengthproperty (likeArgumentsobjects). And even for those that do not, it then just returns an empty array.