This concept surprised me in one of my coding interviews. At the beginning of my career, I had little knowledge of mutable and immutable objects and it backfired without me even realizing the root cause.
In Chapter 5, Store Patterns, I explained the basics of mutability and immutability. We even used the Immutable.js library. That part of the book was heavily focused on the store. Now let's look at the bigger picture. Why do we even need mutable or immutable objects?
Usually, the main reason is the ability to quickly reason about our application's behavior. For instance, React wants to quickly check whether it should re-render components. If you create object A and you are guaranteed that it won't ever change, then to reassure yourself that nothing changed, the only thing you need to do is compare the reference to the object. If it...