Last Updated: February 25, 2016
·
1.222K
· victorquinn

Convert `arguments` into an Array

For a more detailed explanation of arguments, see my blog post

But the quick tip, to convert arguments into an Array, use the following snippet:

var args = Array.prototype.slice.call(arguments);

args will now be a proper Array!

1 Response
Add your response

Since I'm a pretty lazy dev, I tend to use:

var args = [].slice.call(arguments, 0);

probably not as performant as Array.prototype but a lot shorter ;)

over 1 year ago ·