Categories
JavaScript Answers

How to remove first element from array and return the array minus the first element with JavaScript?

Spread the love

To remove first element from array and return the array minus the first element with JavaScript, we call the shift method.

For instance, we write

const myArray = ["item 1", "item 2", "item 3", "item 4"];

myArray.shift();
console.log(myArray);

to call myArray.shift to remove the first item of myArray in place.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *