javascript - Using the push method or .length when adding to array? -


what downsides doing:

var myarray = []; myarray[myarray.length] = val1; myarray[myarray.length] = val2; 

instead of:

var myarray = []; myarray.push(val1); myarray.push(val2); 

i'm sure push method more "acceptable", there differences in functionality?

push way faster, 300% faster.

proof: http://jsperf.com/push-vs-length-test


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -