The JavaScript array shift() method is used to remove and return the first element of an array.
Note: The length of the original array will be modified.
Syntax:
array. shift()
Return:
The first element of an array.
Example:
<!DOCTYPE html> <html> <body> <script> var a = ["GOLD","SILVER","DIAMOND","RUBY","PLATINUM"] var result=a.shift(); document.writeln(result + "<br>"); document.writeln(a); </script> </body> </html>