15.4.4.7 Array.prototype.push([item1[, item2[, ... ]]])

2010-07-05

int Array.prototype.push([item1:mixed[, item2:mixed[, ... ]]])

Add all given arguments in order to the end of the array. Returns the new length of the array.

The this value will be coerced into an object.

Array.prototype.push.length = 1

Code: (Meta Ecma)
Array.prototype.push = function(){
var O = ToObject(this);
var lenVal = O.[[Get]]("length");
var n = ToUint32(lenVal);
var items = Array.prototype.slice.call(arguments); // needs to be an array
while (items.length) {
var E = items.shift();
O.[[Put]](ToString(n), E, true);
}
O.[[Put]]("length", n, true);
return n;
}