JavaScript provides shift() method to remove the first element from array. shift() returns the removed element.
Note: shift() method modifies the original array.
let shoppingList = ["Milk", "Bread", "Garlic"]; console.log(shoppingList); let firstElement = shoppingList.shift(); console.log(shoppingList); console.log(firstElement);
Output
["Milk", "Bread", "Garlic"] ["Bread", "Garlic"] "Milk"