1some_array = ["John", "Sally"];
2some_array.push("Mike");
3
4console.log(some_array); //output will be =>
5["John", "Sally", "Mike"]
1//Use push() method
2//Syntax:
3array_name.push(element);
4//Example:
5let fruits = ["Mango", "Apple"];
6//We want to append "Orange" to the array so we will use push() method
7fruits.push("Orange");
8//There we go, we have successfully appended "Orange" to fruits array!
1
2let chocholates = ['Mars', 'BarOne', 'Tex'];
3let chips = ['Doritos', 'Lays', 'Simba'];
4let sweets = ['JellyTots'];
5
6let snacks = [];
7snacks.concat(chocholates);
8// snacks will now be ['Mars', 'BarOne', 'Tex']
9// Similarly if we left the snacks array empty and used the following
10snacks.concat(chocolates, chips, sweets);
11//This would return the snacks array with all other arrays combined together
12// ['Mars', 'BarOne', 'Tex', 'Doritos', 'Lays', 'Simba', 'JellyTots']
13
1// initialize array
2var arr = [
3 "Hi",
4 "Hello",
5 "Bonjour"
6];
7
8// append new value to the array
9arr.push("Hola");
10
11console.log(arr);