- Mastering Immutable.js
- Adam Boduch
- 96字
- 2021-07-08 10:30:11
Setting map values
The set() method for maps is used to add and to change collection values. If the key that's being set doesn't exist, then the key-value pair is set for the first time. If the key does exist, then the previous value of that key is replaced with the new value, as follows:
const myMap = Map.of('one', 1);
const myChangedMap = myMap.set('one', 'one');
console.log('myMap', myMap.toJS());
// -> myMap { one: 1 }
console.log('myChangedMap', myChangedMap.toJS());
// -> myChangedMap { one: 'one' }
Calling set() produces a new map, because all Immutable.js mutations are persistent changes.
推薦閱讀
- 觸·心:DT時代的大數據精準營銷
- JIRA 7 Administration Cookbook(Second Edition)
- Building Mobile Applications Using Kendo UI Mobile and ASP.NET Web API
- VMware虛擬化技術
- 零基礎學單片機C語言程序設計
- Python Essentials
- 零基礎學C語言第2版
- Mastering Apache Storm
- Oracle Data Guard 11gR2 Administration Beginner's Guide
- JSP程序設計與案例實戰(慕課版)
- C語言程序設計實踐
- 分布式架構原理與實踐
- Learning Grunt
- Mastering Object:Oriented Python(Second Edition)
- Hadoop Blueprints