push– add an element to the beginning/end of an array
pop– remove and return the first/last element of an array
A simple diagram…
unshift -> [array] <- push shift <- [array] -> pop
add remove start end push X X pop X X unshift X X shift X X
Check out the MDN Array documentation. Virtually every language that has the ability to push/pop elements from an array will also have the ability to unshift/shift (sometimes called
pop_front) elements, you should never have to implement these yourself.