update object values in 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: update object within object by id js
//This will replace myId of the item id with the updated object
return myArray.map((item) => {
return item.id === myId
? UPDATED_OBJECT_HERE
: item;
});