Javascript – Using the push method or .length when adding to array

javascript

What are the downsides to doing:

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

instead of:

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

I'm sure the push method is much more "acceptable", but are there any differences in functionality?

Best Answer

push is way faster, almost 300% faster.

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