add data to json object javascript code example

Example 1: javascript append to json

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

test.phone = '234654234';

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

Example 2: how to add element in json object

// base code ----------------------------------------------------------
	object["property"] = value;
	 // or
	object.property = value;
// exampel : ----------------------------------------------------------
	var myJson = { name: "mamad", family: "mirzaei" }
// i wana to add age 
	myJson.age = 26
// log =>
	console.log( "myJson >>:" ,myJson) 
// resalt =>
	{ name: "Mamad", family: "Mirzaei", age : 26 }

Example 3: add to json object javascript

object.property = value;