Q:

javascript push array into array

array.push(element)
27
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
7
some_array = ["John", "Sally"];
some_array.push("Mike");

console.log(some_array); //output will be =>
["John", "Sally", "Mike"]
38
array = ["hello"]
array.push("world");

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

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

fruits.push("Kiwi"); 

console.log(fruits) // ["Banana", "Orange", "Apple", "Mango", "Kiwi"]
3
let items = [1, 2, 3]
items.push(4); // items = [1, 2, 3, 4]
6
let foo = ['oop','plop','copo'];
	foo.push("plop");
6
var SomeRandomArray = [];
SomeRandomArray.push("Hello, world!");
8
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
// initialize array
var arr = [
  "Hi",
  "Hello",
  "Bonjour"
];

// append new value to the array
arr.push("Hola");

console.log(arr);
3

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

fruits.push("Kiwi"); 
0

New to Communities?

Join the community