JAVASCRIPT Tutorial
The push()
method is used to append one or more elements to the end of an array.
Yes, push()
directly modifies the original array.
push()
method on the array.push()
method.const arr = [1, 2, 3];
arr.push(4, 5); // Add 4 and 5 to the end of the array
console.log(arr); // Output: [1, 2, 3, 4, 5]
push()
method returns the new length of the array.push()
.