add item to array code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");
Example 2: js array add element
array.push(element)
Example 3: javascript append element to array
var colors= ["red","blue"];
colors.push("yellow");
Example 4: javascript pushing to an array
some_array = ["John", "Sally"];
some_array.push("Mike");
console.log(some_array);
["John", "Sally", "Mike"]
Example 5: how to add a new item in an array in javascript
let array = ["Chicago", "Los Angeles", "Calgary", "Seattle", ]
console.log(array)
array.push('New Item') < variable_name > .push( < What you want to add > )
console.log("This array has", array.length, "things in it")
Example 6: javascript append element to array
var arr = [
"Hi",
"Hello",
"Bonjour"
];
arr.push("Hola");
console.log(arr);