Adding and Removing Elements
Adding and Removing Elements
push - adds an element to the end of an array.
pop - removes the element at the end of the array. returns the element.
unshift - adds an element to the beginning of an array
shift - removes an element from the beginning of an array. returns the element.
Splicing Elements
splice - combines adding and removing elements in a single method. This method is difficult to learn all the options for the parameters, but you can just focus on the simple use-cases, which are the majority, and it's not too hard.
start: at which index to start the change
deleteCount: the number of elements to remove
items: a comma-separated list of elements to add
Splicing in a single value
Splicing in multiple values
Removing an element in the middle
Replace an element in the middle
Last updated