You are here: Home » NewsFeeds » Immutable.js: An Introduction with examples written for humans

Immutable.js: An Introduction with examples written for humans

Immutable.js is an awesome library for creating Immutable collections of data, hugely popular for React/Redux development, but dogged by horrendous documentation. Struggle no more, with this first in a series of in-depth tutorials, complete with live coding examples.
What is Immutable.js?
Immutable.js (or just Immutable from now on) is a library for creating collections of data, which, once created, cannot be changed. These collections are modelled on JavaScript’s Array, Map and Set objects, but with the significant difference that all methods to add, delete or update data in a collection do not mutate (i.e. change) the collection being acted upon.
For example, Immutable’s push() method, which adds an item of data to an Immutable List, actually adds the item to a new copy of the List, leaving the original List collection completely unchanged.
To see this, the following shows a standard JavaScript Array’s push() method acting on (and mutating) the array itself:

// Standard mutating


Original article