push

Add an element to the end of an array.

listadd valueto end
JavaScript
(method) Array.push(item: T): void;
Python
(method) Array.append(item: T): None

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:

123array ofthoseNumbers4add valueto endsetthoseNumbersto

Parameters

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

Example

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

"cat""dog""parrot""goldfish"array ofpets"guinea pig"add valueto endsetpetstoon start

See also

pop, unshift