remove first element from array javascript
snippet in javascript

javascript remove first element from array

user7456

var arr = [1, 2, 3, 4]; 
var theRemovedElement = arr.shift(); // theRemovedElement == 1
console.log(arr); // [2, 3, 4]

remove a particular element from array

user9424

var colors = ["red","blue","car","green"];
var carIndex = colors.indexOf("car");//get  "car" index
//remove car from the colors array
colors.splice(carIndex, 1); // colors = ["red","blue","green"]

remove first element from array javascript

user1329

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.shift();

remove 1st element from array

user178


var fruits = ["Banana", "Orange", "Apple", "Mango"];

console.log(fruits.shift()); // prints "Banana"
console.log(fruits) // prints ["Orange", "Apple", "Mango"]

removing first item array js

user604


var list = ["bar", "baz", "foo", "qux"];
list.shift()//["baz", "foo", "qux"]

js remove first item

user3534

let myArray = [1, 2, 3, 4, 5];

let removedElement = myArray.shift();