---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# Array.prototype.shift()

The **`shift()`** method removes the **first**
element from an array and returns that removed element. This method changes the length
of the array.

## Syntax

```js
shift()
```

### Return value

The removed element from the array; [`undefined`](../../../globals/undefined.mdx) if the array is empty.

## Description

The `shift()` method removes the element at the zeroth index and shifts the
values at consecutive indexes down, then returns the removed value. If the
[`Array.prototype.length`](./length.mdx) property is 0, [`undefined`](../../../globals/undefined.mdx) is returned.

The [`Array.prototype.pop()`](./pop.mdx) method has similar behavior to `shift()`, but applied to the last element in an array.

The `shift()` method is a mutating method. It changes the length and the content of `this`. In case you want the value of `this` to be the same, but return a new array with the first element removed, you can use [`arr.slice(1)`](./slice.mdx) instead.

The `shift()` method is generic. It only expects the `this` value to have a `length` property and integer-keyed properties. Although strings are also array-like, this method is not suitable to be applied on them, as strings are immutable.
