Changing an object is about changing properties on it as well as adding properties to it. First off, let's look at how to change existing values:
// core-concepts/object.js// the old waylet anakin = { name: "anakin" };anakin.name = "darth";console.log(anakin);// the Redux waylet anakinRedux = { name: "anakin" };let darth = Object.assign({}, anakinRedux, { name: "darth" });console.log(anakinRedux);console.log(darth);
That covers the existing case. What about adding a new property? We can do that like so:
// core-concepts/object-add.js// the old waylet anakin = { name: "anakin" };console.log("anakin", anakin);anakin["age"] = "17";console.log("anakin with age", anakin);// the Redux waylet anakinImmutable = { name: "anakin" ...