add element to end of array javascript code example
Example 1: javascript add new array element to start of array
var colors = ["white","blue"];
colors.unshift("red");
Example 2: append array js
var colors= ["red","blue"];
colors.push("yellow");
Example 3: javascript pushing to an array
some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array);
["John", "Sally", "Mike"]
Example 4: js add element to front of array
var numbers = ["2", "3", "4", "5"];
numbers.unshift("1");
Example 5: javascript array add end
let yourArray = [1, 2, 3];
yourArray.push(4);
Example 6: javascript append element to array
var arr = [
"Hi",
"Hello",
"Bonjour"
];
arr.push("Hola");
console.log(arr);