filmov
tv
Array shift method in javascript

Показать описание
The shift() method allows you to remove the first element from an array and returns that element. It also modifies the original array.
Here's an example:
const myArray = [1, 2, 3, 4, 5];
In this example, shift() removes the first element (1) from the array. The shifted element is stored in the shiftedElement variable, and the updated array is displayed.
You can use shift() when you want to remove and retrieve the first element of an array.