Overview of Immutable.js
Immutable.js provides persistent data structures where any modification, addition, or deletion returns a new immutable object rather than mutating the original. This approach reduces complexity associated with mutable state, saves memory, and enables features like Undo/Redo and functional programming patterns.
Caveats:
- It is easy to accidentally mix immutable objects with native JavaScript objects. It is recommended to use
fromJSfor creation and prefix immutable variables with$$to distinguish them. - Since every operation returns a new object, developers must remember to assign the result to a variable.