September 2017
Intermediate to advanced
216 pages
6h 8m
English
You can pass native JavaScript collections, such as objects and arrays, to Immutable.js collections, such as maps and lists. This is one way to provide immutable collections with initial values. For example, you can pass the list constructor an array, as follows:
const myList = List([1, 2, 3]);console.log('myList', myList.get(1));// -> myList 2
The Map constructors work the same way, except you pass it an object:
const myMap = Map({ a: 1, b: 2, c: 3 });console.log('myMap', myMap.get('b'));// -> myMap 2
Read now
Unlock full access