The shift() method is used to remove the first element from an array.
- Removes the first element (index 0) of an array
- Modifies the original array
- Returns the removed element
- Re-indexes all remaining elements → slower than pop()
The shift() method is used to remove the first element from an array.
shift()shift() on an Empty ArrayPrevious Article
Next Article