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

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.

主站蜘蛛池模板: 防城港市| 海宁市| 贵州省| 桂东县| 定安县| 德化县| 河西区| 阿克陶县| 永宁县| 普定县| 吴川市| 景德镇市| 凤凰县| 嘉祥县| 湟源县| 浠水县| 汾阳市| 富阳市| 郯城县| 延边| 丹寨县| 永安市| 盐山县| 万源市| 通辽市| 梅州市| 乌什县| 肇源县| 尼木县| 武定县| 济南市| 高州市| 无锡市| 东丰县| 武宁县| 泸溪县| 内黄县| 彝良县| 祥云县| 沾益县| 枣庄市|