unshifth js code example
Example 1: javascript unshift
let array = ["A", "B"];
let variable = "what you want to add";
//Add the variable to the beginning of the array
array.unshift(variable);
//===========================
console.log(array);
//output =>
//["what you want to add" ,"A", "B"]
Example 2: .unshift
let monTableau = ['un', 'deux','trois', 'quatre'] ;
monTableau.unshift('zero') ;
//console.log(monTableau) ;
let monTableau2D = [
['Mark' , 'jeff' , 'Bill'] ,
['Zuckerberg' , 'Bezos' , 'Gates']
] ;
monTableau2D[1].unshift('test') ;
//console.log(monTableau2D) ;