EN
JavaScript - remove first element from array
0
points
In this article, we would like to show you how to remove the first element from an array in JavaScript.
Quick solution:
// ONLINE-RUNNER:browser;
var array = ['a', 'b', 'c'];
array.shift();
console.log(array); // [ 'b', 'c' ]
Alternative solution
In this example, we use slice() method to remove the first element from array.
// ONLINE-RUNNER:browser;
var array = ['a', 'b', 'c'];
var newArray = array.slice(1);
console.log(newArray); // [ 'b', 'c' ]