Q:

push javascript

array.push(element)
27
array.push(element_to_push);
10
some_array = ["John", "Sally"];
some_array.push("Mike");

console.log(some_array); //output will be =>
["John", "Sally", "Mike"]
38
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi"); // Fruits = ["Banana", "Orange", "Apple", "Mango", "Kiwi"];
9
let array = ["A", "B"];
let variable = "what you want to add";

//Add the variable to the end of the array
array.push(variable);

//===========================
console.log(array);
//output =>
//["A", "B", "what you want to add"]
12
var array = [];
var element = "anything you want in the array";
array.push(element); // array = [ "anything you want in the array" ]
11

var fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.push("Kiwi"); 
0
array = ["hello"]
array.push("world");

console.log(array);
//output =>
["hello", "world"]
15
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
7
var fruits = ["222", "vvvv", "eee", "eeee"];

fruits.push("Kiwi"); 
11
const animals = ['pigs', 'goats', 'sheep'];

const count = animals.push('cows');
console.log(count);
// expected output: 4
console.log(animals);
// expected output: Array ["pigs", "goats", "sheep", "cows"]

animals.push('chickens', 'cats', 'dogs');
console.log(animals);
// expected output: Array ["pigs", "goats", "sheep", "cows", "chickens", "cats", "dogs"]
2
let fruit = ['apple', 'banana']
fruit.push('cherry')
console.log(fruit) // ['apple', 'banana', 'chery']
2
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) ;

1

New to Communities?

Join the community