Using the shift method

To remove an element from the beginning of the array, we can use the shift method, as follows:

numbers.shift(); 

If we consider that our array has the value -4 to 12 and a length of 17 after we execute the previous code, the array will contain the values -3 to 12 and have a length of 16.

The shift and unshift methods allow an array to emulate a basic queue data structure, which is the subject of Chapter 5, Queues and Deques .