push object into array javascript code example

Example 1: js array add element

array.push(element)

Example 2: javascript append element to array

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

Example 3: js add item to array

var fruits = ["Banana", "Orange", "Apple", "Mango"];
fruits.push("Kiwi");

Example 4: pushing element in array in javascript

array = ["hello"]
array.push("world");

Example 5: how to add objects in array

var a=[], b={};
a.push(b);    
// a[0] === b;

Example 6: push object into array javascript

var nietos = [];
var obj = {};
obj["01"] = nieto.label;
obj["02"] = nieto.value;
nietos.push(obj);