Javascript examples for Array:shift
The shift() method removes the first item of an array, and returns that item.
None
the removed array item.
The following code shows how to Remove the first item of an array:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> var fruits = ["a","b","c","d","e"]; document.getElementById("demo").innerHTML = fruits; function myFunction() {/* w w w. j av a 2s . c o m*/ fruits.shift(); document.getElementById("demo").innerHTML = fruits; } </script> </body> </html>