push() / pop()
Adds to / removes from the end.
Syntax
arr.push(e) · arr.pop()
Description
push adds an element and returns the new length; pop removes the last element and returns it.
Example
Loading editor…
Expected output
[ 1, 2, 3 ] 3
When to use?
Stack, growing lists, queue.