Modify or Set Data

example1 / example2

var x = [
  {"name1": "value1", "name2": "value1”},
  {" name1": "value2", " name2": "value2”}
];

x[0].name1="newValue";
document.getElementById("id").innerHTML = x[0].name1 + " " + x[0].name2;

OR

x[0]["name1"]="newValue";
document.getElementById("id").innerHTML = x[0]["name1"] + " " + x[0]["name2"];
Advertisements

About bernadetteengleman

Hello, I am Bernadette from New York City. I moved here from Chicago in 2013. I am originally from the Philippines. I started studying web programming in 2015. I love it because I like making fun websites and web apps. The projects that I built so far are posted below. I like to cook and I love to travel. I also like to volunteer and I am a team leader with the non-profit organization, NYCares.
This entry was posted in JSON and tagged , , . Bookmark the permalink.