官术网_书友最值得收藏!

  • 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.

主站蜘蛛池模板: 北辰区| 东安县| 吴忠市| 淳安县| 虎林市| 静乐县| 大英县| 汝阳县| 万全县| 安义县| 措勤县| 绥化市| 江油市| 右玉县| 梁平县| 临西县| 邵东县| 沐川县| 南木林县| 原阳县| 普格县| 兴安盟| 淮安市| 宁国市| 平潭县| 温州市| 德州市| 商河县| 顺昌县| 鄂尔多斯市| 岳池县| 濮阳市| 会昌县| 长葛市| 登封市| 沭阳县| 竹北市| 肇源县| 绥德县| 涿鹿县| 遂溪县|