Andy
0
Q:

array push

array.push(element)
27
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
7
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
// JS array .push() method

let items_in_backpack = ['food', 'water', 'flashlight', 'GPS']; // Our starting array
items_in_backpack.push('javascript array push knowledge'); // Adds the <<< string to the array items_in_backpack


// Now the array is:
// ['food', 'water', 'flashlight', 'GPS', 'javascript array push knowledge']

2
array = ["hello"]
array.push("world");

console.log(array);
//output =>
["hello", "world"]
15
var vegetables = ['Capsicum',' Carrot','Cucumber','Onion'];
vegetables.push('Okra');
//expected output ['Capsicum',' Carrot','Cucumber','Onion','Okra']; 
// .push adds a thing at the last of an array
7

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

fruits.push("Kiwi"); 
0

Tags

Related

New to Communities?

Join the community