1var colors = ["red","blue","car","green"];
2var carIndex = colors.indexOf("car");//get "car" index
3//remove car from the colors array
4colors.splice(carIndex, 1); // colors = ["red","blue","green"]
1var arr = [1, 2, 3, 4];
2var theRemovedElement = arr.shift(); // theRemovedElement == 1
3console.log(arr); // [2, 3, 4]
1const array1 = [1, 2, 3];
2
3const firstElement = array1.shift();
4
5console.log(array1);
6// expected output: Array [2, 3]
7
8console.log(firstElement);
9// expected output: 1
1//The shift() method removes the first element from an array
2//and returns that removed element.
3//This method changes the length of the array.
4
5const array1 = [1, 2, 3];
6const firstElement = array1.shift();
7console.log(array1);
8// expected output: Array [2, 3]
9console.log(firstElement);
10// expected output: 1
11