JavaScript – Add an Element at the End of Array

To add and element at the end of array in JavaScript, call push() method on this array and pass the element as argument.

The syntax to add/append an element e to the end of an array arr is

arr.push(e)

Example

In the following example, we create an array with three elements, and add an element 'orange' to the end of this array.

Example

ADVERTISEMENT

Conclusion

In this JavaScript Tutorial, we learned how to append/add an element to the end of an Array in JavaScript, with examples.