javascript how to push to array code example
Example 1: js add item to array
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
Example 2: js push array
array.push(element_to_push);
Example 3: js push array
var array = [];
var element = "anything you want in the array";
array.push(element);
Example 4: javascript array push
var fruits = [ "Orange", "Apple", "Mango"];
fruits.push("Banana");
Example 5: .push js
let monTableau2D = [
['Mark' , 'jeff' , 'Bill'] ,
['Zuckerberg' , 'Bezos' , 'Gates']
] ;
monTableau2D[1].push('test') ;
console.log(monTableau2D) ;
let monTableau = ['un', 'deux','trois', 'quatre'] ;
monTableau.push('cinq') ;
console.log(monTableau) ;
let monTableauAssociatif = {
'prenom' : 'Mark' ,
'nom' : 'Zuckerberg' ,
'poste' : 'Pdg de Facebook',
} ;
monTableauAssociatif['nationalite'] = 'Américaine' ;
console.log(monTableauAssociatif) ;