JavaScript: Array.prototype.push

By Xah Lee. Date: . Last updated: .
arrayX.push(new1, new2 etc)
Adds items to the end of the array arrayX. Return the new length.
const xx = [3];

const xy = xx.push(7, [8]);

console.log(xy === 3);
console.log(JSON.stringify(xx) === "[3,7,[8]]");

To join arrays by flattening 1 level, see Array.prototype.concat .

To flatten nested array, see Array.prototype.flat .

JavaScript: Array, add/remove items

BUY
ΣJS
JavaScript in Depth