how to push an element into an array in javascript


var colors=["red","white"];
colors.push("blue");//append 'blue' to colors

array.push(element)

var colors= ["red","blue"];
colors.push("yellow");

// initialize array
var arr = [
"Hi",
"Hello",
"Bonjour"
];

// append new value to the array
arr.push("Hola");

console.log(arr);

var fruits = ["Banana", "Orange", "Apple", "Mango"];

fruits.push("Kiwi");

www.codegrepper.com
www.stackoverflow.com