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!
Written by Victor Quinn
Related protips
1 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
Best
#Arguments
Authors
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
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#