through one reference, one can make a change that is visible to all other references. • In contrast, an immutable object is one where this is not possible. • Making a change to an immutable object thus requires crea?ng a new object, with its own set of references.
code has a reference to one, it is guaranteed not to change • This makes it much easier to decouple parts of a program; references to mutable objects can expose the internals of one piece of code to another. • This is responsible, for example, for the predictability and debuggability of Redux.
integer literals were mutable references: c This prints 6: PRINT *, (5 + 1) c Seriously, this worked at one point: 5 = 7 c This prints 8: PRINT *, (5 + 1) • This allowed one stray statement to change the meaning and correctness of the whole program.
structures, rather than changing the structure itself, return new structures containing the new data. • If the en're structure is immutable, this allows efficient copies; parts of the structure that do not change can be references to the same parts in the previous structure.
a variety of immutable data structures in Javascript, including: • Map • List • Set • These present a different API from the similar plain Javascript objects, but have similar capabiliDes
manages is kept immutably • Immutable objects can perform a wide variety of opera>ons efficiently • Immutable allows efficient deep comparison of large data structures
than plain Javascript objects • Repeated conversions between Immutable and plain objects are inefficient • (though this is why I wrote reselect-immutable- helpers) • Immutable is a bit large in size
to reason about • While not a first-class construct in Javascript, it is straigh<oward to operate immutably on Javascript data structures • Immutable.JS is a powerful library for efficiently building immutable data structures