how to push elements in an array in javascript code example
Example 1: javascript append to array
var colors=["red","white"];
colors.push("blue");//append 'blue' to colors
Example 2: js array add element
array.push(element)
Example 3: push array javascript
let array = ["A", "B"];
let variable = "what you want to add";
//Add the variable to the end of the array
array.push(variable);
//===========================
console.log(array);
//output =>
//["A", "B", "what you want to add"]
Example 4: javascript add item to list
var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");
Example 5: how to push items in array in javascript
let items = [1, 2, 3]
items.push(4); // items = [1, 2, 3, 4]