The shift() method removes the first item from an array.
The shift() method removes the first item from an array.
It changes the length of the array and returns the removed item.
You can remove the last item of an array, use the pop() method.
array.shift()
None
Any type, representing the removed array item.
An array item can be of type string, number, array, boolean, or any other object types.
Remove the first item of an array:
var myArray = ["XML", "Json", "Database", "Mango"]; console.log( myArray );//from w w w. j a v a2s . com myArray.shift(); console.log( myArray ); var x = myArray.shift(); console.log( myArray ); console.log(x);