JavaScriptArraypush

Adds elements to the end of an array and returns the new length.

Syntax

arr.push(...elements)

Example

Enter values below to update the example in real time.

const
arr
newLen
push
console
const arr = [1, 2, 3];
const newLen = arr.push(4, 5);
console.log(newLen);   // 5
console.log(arr);      // [1, 2, 3, 4, 5]