Courses / JavaScript
11. Array.prototype.shift()
Removes the first element from an array and returns that element.
1 min read Chapter 11 of 99
JavaScript
Array.prototype.shift()
Array.prototype.shift() removes the first element from an array and returns it.
"I need to manage a queue of tasks, but I want to remove the oldest task first."
The `shift()` method modifies an array by removing its first element and returns that element, shifting all subsequent elements down one index.
"I need to manage a queue of tasks, but I want to remove the oldest task first."
The `shift()` method modifies an array by removing its first element and returns that element, shifting all subsequent elements down one index.