JavaScript Array shift() Method


The JavaScript Array shift() method removes the first element from an array and returns that element.

The JavaScript array shift() method removes the first element of the given array and returns that element. This method changes the length of the original array.

Syntax

array.shift()

Example

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.shift();

Example -