append object to list javascript code example
Example 1: javascript append element to array
var colors= ["red","blue"];
colors.push("yellow");
Example 2: how to add objects in array
var a=[], b={};
a.push(b);
// a[0] === b;
Example 3: javascript add element to array
const langages = ['Javascript', 'Ruby', 'Python'];
langages.push('Go'); // => ['Javascript', 'Ruby', 'Python', 'Go']
const dart = 'Dart';
langages = [...langages, dart]; // => ['Javascript', 'Ruby', 'Python', 'Go', 'Dart']
Example 4: how to add object to list in javascript
var a=[]
var b={};
a.push(b);
Example 5: how to add object to array javascript
var object = "Some Object"
var array = []
array.push(object)