- Mastering Immutable.js
- Adam Boduch
- 54字
- 2021-07-08 10:30:08
Maps of values
You can use the of() method to create key-value maps:
const myMap = Map.of(
'a', 1,
'b', 2,
'c', 3
);
console.log('myMap', myMap.toJS());
// -> myMap { a: 1, b: 2, c: 3 }
The trick here is to alternate between the key and value arguments that are passed to of().