1var colors = ["white","blue"];
2colors.unshift("red"); //add red to beginning of colors
3// colors = ["red","white","blue"]
1//see https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Objets_globaux/Array/unshift
2
3const array1 = [1, 2, 3];
4
5console.log(array1.unshift(4, 5));
6// expected output: 5
7
8console.log(array1);
9// expected output: Array [4, 5, 1, 2, 3]
1 let array = ["A", "B"];
2 let variable = "what you want to add";
3
4//Add the variable to the beginning of the array
5 array.unshift(variable);
6
7//===========================
8 console.log(array);
9//output =>
10//["what you want to add" ,"A", "B"]
1const array1 = [1, 2, 3];
2
3console.log(array1.unshift(4, 5));
4// expected output: 5
5
6console.log(array1);
7// expected output: Array [4, 5, 1, 2, 3]