JS Main Array Methods Flashcards
PUSH
.push(condition);
Adds an item to the end of an array
// NOTE: PUSH also returns (shows) the new number of items in the array.
POP
.pop();
Pop removes the item at the end of an array
NOTE: POP also returns (shows) the value of the item that was removed from the end of the array
SHIFT
.shift();
(Removes the item at the start of an array (AKA Item at index of Zero). Also, moves all leftover items in the array one space/index to the left)
NOTE: SHIFT also returns (shows) the value of the item that was removed from the start of the array
UNSHIFT
.unshift(condition);
Adds a new item to the start of an array (AKA at the index of Zero). Also, moves all items in the array one space/index to the right.)
// NOTE: UNSHIFT also returns (shows) the new number of items in the array.