add item to array javascript stackoverflow code example
Example 1: javascript append to array stack overflow
// initialize array
var arr = [
"Hi",
"Hello",
"Bonjour"
];
// append new value to the array
arr.push("Hola");
console.log(arr);
Example 2: js push to array site:stackoverflow.com
// initialize array
let arr = ['Hi', 'Hello', 'Bonjour'];
let arr2 = new Array('Hi', 'Hello', 'Bonjour');
// append new value to the array
arr.push("Hola");
arr2.push("Hola");