push object to array in js code example
Example 1: javascript add object to array
var object = {'Name'};
var array = [ ];
array.push(object);
array.unshift(object);
array.splice(position, 0, object);
Example 2: add object to array javascript
let obj = { name: 'Bob' };
let arr = [{ name: 'John' }];
arr = [...arr, obj];
console.log(arr)
Example 3: Add object to array javascript
var object = "Some Object"
var array = []
array.push(object)
Example 4: javascript array push object
var myArray = [];
myArray.push("Example");
myArray.push("text");