How ImmutableJS works

In this lesson, we'll take a quick look at the internals of ImmutableJS so that we have a better understanding of how can we apply Immutable.js to our Redux app in a performant manner.

Immutable data structures can’t be changed. So when we convert a regular JavaScript object with fromJS what ImmutableJS does is loop over every single property and value in the object (including nested objects and arrays) and transfers it to a new, immutable one. (the same thing applies in the other direction for toJS)

The problem with standard JavaScript objects is that they have reference equality. That means even when two objects have the same content, they’re not the same:

Get hands-on with 1200+ tech skills courses.