Pre Exam Test Practice (SSC | Banking | IAS | GATE | State Level | CLAT | Railways | Insurance | Teaching Exams | NDA | Defence | IES |State Exam )

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 15, 2015 by CarriDugaslx
0 votes
3 views



Related Hot Questions



Government Jobs Opening


...