olivia
0
Q:

javascript shift


var list = ["bar", "baz", "foo", "qux"];
list.shift()//["baz", "foo", "qux"]
12
let array = ["A", "B", "C"];

//Removes the first element of the array
array.shift();

//===========================
console.log(array);
//output =>
//["B", "C"]
7
//The shift() method removes the first element from an array 
//and returns that removed element. 
//This method changes the length of the array.

const array1 = [1, 2, 3];
const firstElement = array1.shift();
console.log(array1);
// expected output: Array [2, 3]
console.log(firstElement);
// expected output: 1
2
const array1 = [1, 2, 3];

const firstElement = array1.shhift();

console.log(array1);
// output: Array [2, 3];
https://developer.mozilla.org/pt-BR/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
0
let monTableau2D = [
     ['Mark' , 'jeff' , 'Bill'] , 
     ['Zuckerberg' , 'Bezos' , 'Gates']
 ] ;
 monTableau2D[0].shift() ; 
 console.log(monTableau2D) ; 
0
var colors = ["Red", "Orange", "Yellow", "Green"]
colors.shift()
-1

New to Communities?

Join the community