1
2var list = ["bar", "baz", "foo", "qux"];
3list.shift()//["baz", "foo", "qux"]
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
1let array = ["A", "B", "C"];
2
3//Removes the first element of the array
4array.shift();
5
6//===========================
7console.log(array);
8//output =>
9//["B", "C"]
1const arr = ['foo', 'bar', 'qux', 'buz'];
2
3arr.shift(); // 'foo'
4arr; // ['bar', 'qux', 'buz']
1
2const fruits = ["Banana", "Orange", "Apple", "Mango"];
3
4fruits.shift(); // Removes "Banana" from fruits
5