Quick question that I haven't really had a chance to look into. Which is more performant when used in a call/apply sort of context: Array.prototype vs []?
e.g.:
function test1() {
return Array.prototype.splice.apply(arguments, [1, 2]);
}
test1([1,2,3,4,5,6,7,8,9]);
function test2() {
return [].splice.apply(arguments, [1, 2]);
}
test1([1,2,3,4,5,6,7,8,9]);
My thoughts: I would assume the Array.prototype way is more performant because a prototype function can be reused and no literal need be created. Not really sure though.
Using JSPerf (with chrome) it looks like the Array.prototype is indeed slightly more performant: