update key value in object javascript code example

Example 1: 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 2: how to update object in javascript

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

Example 3: update a certain key in dictionary javascript

const target = {c: 4, d: 5}
const source = {a: 1, b: 2, c: 3};

const newObj = Object.assign({}, target, source);

console.log(newObj); //=> {a: 1, b: 2, c: 3, d: 5}