Last Updated: February 25, 2016
·
1.553K
· 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 ·

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside