shift() / unshift()
Removes from / adds to the beginning.
Syntax
arr.shift() · arr.unshift(e)
Description
shift removes and returns the first element; unshift adds to the beginning.
Example
Loading editor…
Expected output
1 [ 0, 2, 3 ]
When to use?
Queue, processing from the front.