Organizational Research By

Surprising Reserch Topic

why is arr faster than arr new array


why is arr faster than arr new array  using -'javascript,performance'

I ran this code and got the below result. I curious to know why [] is faster?

console.time('using[]')
for(var i=0; i<200000; i++){var arr = []};
console.timeEnd('using[]')

console.time('using new')
for(var i=0; i<200000; i++){var arr = new Array};
console.timeEnd('using new')



using[]: 299ms
using new: 363ms


Thanks to Raynos here is a benchmark of this code and some more possible way to define a variable.


    
asked Sep 14, 2015 by AlannaVarghe
0 votes
4 views



Related Hot Questions



Government Jobs Opening


...