The Immutable.js API exposes immutable collections as classes. You then use these classes to create new collection instances. This is just like any other object-oriented JavaScript API that exposes classes. There is one important difference, though—these aren't real classes.
There are a number of internal implementation reasons for why Immutable.js doesn't expose actual classes as its API. One reason is that in some cases, collection instances can be reused, such as when creating empty collections. The only thing to keep in mind is that you never need to use the new
keyword when creating Immutable.js data.
The entirety of the Immutable.js API is represented by the following types:
- Lists
- Maps
- Ordered maps
- Sets
- Ordered sets
- Sequences
- Stacks
- Records
Of these types, we'll only use a few consistently throughout the applications in this book. Each type has it's own operations exposed as methods, and you can easily change from one collection type to...