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

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -