A quick question is that I really didn’t have the opportunity to peek. What is more convenient when used in a call / application context: Array.prototype vs [] ?
eg:.
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 suggest that the Array.prototype method Array.prototype more efficient because the prototype function can be reused and no need to create literals. Not really sure though.
Using JSPerf (with chrome), it looks like Array.prototype really a bit more efficient:
http://jsperf.com/array-perf-prototype-vs-literal
Peter Dev
source share