shift() Function is used to remove first array element and shifts other elements to the left.
Let us say, we have a Array that contains four names, Mohan, Kriti, Philip and Salim. And we want to remove the first name Mohan from the Array.
<html> <body> <script> var x = ["Mohan", "Kriti", "Philip", "Salim"] x.shift() document.write(x) </script> </body> </html>
So, all we have done is, used the shift() method to delete the name Mohan from the beginning of the Array.
x.shift()
And what happens is Mohan gets removed from index 0 pushing all other elements to the left.