Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

slice arguments

View slice_args.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
(function() {
var bench = function(func, t) {
var start = new Date()
, i = t || 100000;
while (i--) func(1, 2, 3);
console.log('%s: %sms', func.name, new Date() - start);
};
 
var slice = Array.prototype.slice;
bench(function _slice() {
var args = slice.call(arguments);
args.unshift(1);
});
 
bench(function _for() {
var l = arguments.length;
var args = new Array(l + 1);
args[0] = 1;
for (var i = 0; i < l; i++) args[i+1] = arguments[i];
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.