- 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.
推薦閱讀
- 復(fù)雜軟件設(shè)計之道:領(lǐng)域驅(qū)動設(shè)計全面解析與實戰(zhàn)
- Java 9 Concurrency Cookbook(Second Edition)
- 架構(gòu)不再難(全5冊)
- Android Development with Kotlin
- PyTorch自然語言處理入門與實戰(zhàn)
- FreeSWITCH 1.6 Cookbook
- Mastering Unity Shaders and Effects
- Keras深度學習實戰(zhàn)
- jQuery炫酷應(yīng)用實例集錦
- 打開Go語言之門:入門、實戰(zhàn)與進階
- 大話Java:程序設(shè)計從入門到精通
- Java EE企業(yè)級應(yīng)用開發(fā)教程(Spring+Spring MVC+MyBatis)
- Python自然語言理解:自然語言理解系統(tǒng)開發(fā)與應(yīng)用實戰(zhàn)
- Hands-On Robotics Programming with C++
- C/C++語言程序開發(fā)參考手冊