Answers for "add new element to existing json object"

3

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 }
Posted by: Guest on June-15-2020
0

add new element to existing json object

json = JSON.stringify(jsObj);
 console.log(json)
Posted by: Guest on January-01-2021

Code answers related to "add new element to existing json object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language