Shift Array | Remove First Element From Array | JavaScript


Remove First Element From Array or Shift Array using JavaScript.

You can use JavaScript array shift method to remove the first element from the array.

let arr = [1,2,3,4,5]
let removed_elem = arr.shift();
console.log('Modified array is ', arr);
console.log('Removed elem is ', removed_elem);

// -   "Modified array is ", [2, 3, 4, 5]
// -   "Removed elem is ", 1

shift method shifts elements to the left and returns the first element.