In ActionScript 2, function arguments come nicely pre-packaged in an Array, so we can use methods like slice and pop to manipulate and travel arbitrary arguments.

Not so in JavaScript. Function arguments are considered a ‘collection’ – basically an object with indexed keys and a length property, but none of the handy methods available to members of the Array class.

Here’s a simple way to transfer all function arguments to an Array object. I’ve seen this done a number of ways, but this (IMHO) is the most elegant.


I’ve seen most people use the following, but am not sure why – I’d be interested in learning why this is apparently preferred.