JavaScript Array shift() method

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

The shift() method is represented by the following syntax:

Return

The first element of an array.

JavaScript Array shift() method example

Let's see an example to remove and return the first element of an array.

Example

Test it Now

Output:

AngularJS





Latest Courses