Array.shift
Array.shift
Function
Delete and return the first element of the array.
Syntax
array.shift()
Parameters
No parameters.
Return value
| Type | Description |
|---|---|
| Any/Empty | Returns the deleted element if the array is not empty; returns Empty for an empty array. |
Example
items = [1, 2, 3] result = items.shift() // Output: 1 print result
Notes
- This method will modify the original array.