Utilizor
Contact Us

push, pop, shift, unshift

Adding and removing elements.

Adding and Removing Elements

pop() removes the last element from an array.

push() adds a new element to an array (at the end).

shift() removes the first array element and "shifts" all other elements to a lower index.

unshift() adds a new element to an array (at the beginning), and "unshifts" older elements.

Example

const fruits = ["Banana", "Orange"];
fruits.push("Kiwi");