Array.prototype.pushbeginnerconst arr = [1, 2]
arr.push(3) // returns 3 (new length)
arr // β [1, 2, 3]Use push() to add one element to the end of an array and get the new length.
push() appends one or more elements to the end of an array and returns the new length of the array.
const arr = [1, 2]
const newLen = arr.push(3) // newLen === 3, arr === [1, 2, 3]