Data Lists
An array is a data structure where elements are stored in order and have numeric indices.
Methods for the End of the Array
- push: Adds an element to the END.
- pop: Removes an element from the END.
Methods for the Beginning (slow)
- shift: Removes an element from the BEGINNING.
- unshift: Adds an element to the BEGINNING.
let fruits = ["Apple", "Orange"];
fruits.push("Pear"); // ["Apple", "Orange", "Pear"]
alert( fruits.pop() ); // "Pear"
Warning
shift and unshift run slowly on large arrays because calling them requires " renumbering " all other elements. push and pop run instantly.