change object values code example

Example 1: JavaScript: Updating Object Properties

var myDog = {
  "name": "Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["freeCodeCamp Campers"]
};

// Update the name value
myDog.name = "Happy Coder";

Example 2: js change value in object

var object = { boo:true, baa:5 };
console.log(object);
function change() {
  object.boo = false;
  object.baa++;
};
change();
console.log(object);
//Hope this helps!

Example 3: how to update object in javascript

myObject['first name'] = 'John'; // property name with a space

Example 4: how to change object property value in javascript

myObject.sProp = 'A new string value for our original string property';