Easy Tutorial
❮ Dom Obj Link Prop Keygen Name ❯

JavaScript shift() Method

JavaScript Array Object

Example

Removing an element from the array:

fruits output result:


Definition and Usage

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

Note: This method changes the length of the array!

Tip: To remove the last element of an array, use the pop() method.


Browser Support

All major browsers support the shift() method.


Syntax

Return Value

Type Description
Any type (*) The value of the original first element of the array (the removed element).

*: Array elements can be a string, number, array, boolean, or other object types.

Technical Details

| JavaScript Version: | 1.2 | | --- | --- |


JavaScript Array Object

❮ Dom Obj Link Prop Keygen Name ❯