Add an element to the end of an array.


You might have an array with 3 numbers, like 1, 2, and 3. If you want to add another number to the end, then you push it on to the array. You do it like this:

let thoseNumbers = [1, 2, 3];


  • item: the element to add to the end of the array.


Add another animal to the end of your list of favorite pets.

let pets = ["cat", "dog", "parrot", "goldfish"];
pets.push("guinea pig");

See also

pop, unshift