append json object javascript code example

Example 1: object javascript append

var list = [];

list.push({name:'John', last_name:'Doe'});
list.push({name:'Jane', last_name:'Doe'});

console.log(list);
/* Result:
[
  {
    "name": "John",
    "last_name": "Doe"
  },
  {
    "name": "Jane",
    "last_name": "Doe"
  }
]
*/

Example 2: javascript append to object

var alerts = [ 
    {num : 1, app:'helloworld',message:'message'},
    {num : 2, app:'helloagain',message:'another message'} 
]

Example 3: javascript append to json

let test = {
		name: 'NN',
  		email: '[email protected]'
};

test.phone = '234654234';

// result { "name": "NN", "email": "[email protected]", "phone": "234654234" }