JavaScript Code

How to append an Element to Array in JavaScript?

Append an Element to Array in JavaScript

In this tutorial, you are given an element and array. You should write a JavaScript program to append the element to array.


To append given element to an array, use JavaScript array method push(). call push() on the array object and pass the element as argument.


Append item element to the array fruits.

let fruits = ['apple', 'banana', 'cherry'];
let item = 'mango';

copyright @2022