Possible Duplicate:
[].slice or Array.prototype.slice
the first
(function() {
var slice = Array.prototype.slice,
aArguments = slice.apply(arguments);
})(10, 20, 30);
the second
(function() {
var aArguments = [].slice.apply(arguments);
})(10, 20, 30);
what’s the difference?
only Speed?
Just different means of getting the same
.slice()method. Methods onArray.prototypeare available from allArrayobjects.The first one requires more object property lookups.
The second one requires the creation of a new Array
Performance considerations will likely vary between implementations, and are likely minor.
Note that you can also do this if you want all the arguments…