xxxxxxxxxx
const vegetables = ['parsnip', 'potato'];
const moreVegs = ['celery', 'beetroot'];
// Merge the second array into the first one
vegetables.push(moreVegs);
console.log(vegetables); // ['parsnip', 'potato', 'celery', 'beetroot']
xxxxxxxxxx
var fruits = ["Orange", "Apple", "Mango"];
var moreFruits = ["Banana", "Lemon", "Kiwi"];
fruits.push(moreFruits);
//fruits => ["Orange", "Apple", "Mango", "Banana", "Lemon", "Kiwi"]
xxxxxxxxxx
//the array comes here
var numbers = [1, 2, 3, 4];
//here you add another number
numbers.push(5);
//or if you want to do it with words
var words = ["one", "two", "three", "four"];
//then you add a word
words.push("five")
//thanks for reading
xxxxxxxxxx
// Add to the end of array
let colors = ["white","blue"];
colors.push("red");
// ['white','blue','red']
// Add to the beggining of array
let colors = ["white","blue"];
colors.unshift("red");
// ['red','white','blue']
// Adding with spread operator
let colors = ["white","blue"];
colors = [colors, "red"];
// ['white','blue','red']
xxxxxxxxxx
var arrayA = [1, 2];
var arrayB = [3, 4];
var newArray = arrayA.concat(arrayB);