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

  • Mastering Immutable.js
  • Adam Boduch
  • 88字
  • 2021-07-08 10:30:12

Removing values from maps

Maps have a remove() method that works the same way as the list version. The only difference is that it takes a key as the argument instead of an index:

const myMap = Map.of(
'one', 1,
'two', 2,
'three', 3
);
const myChangedMap = myMap.remove('one');

console.log('myMap', myMap.toJS());
// -> myMap { one: 1, two: 2, three: 3 }
console.log('myChangedMap', myChangedMap.toJS());
// -> myChangedMap { three: 3, two: 2 }

By calling remove('one') on myMap, you get myChangedMap, a new map without the removed key.

主站蜘蛛池模板: 临沧市| 商丘市| 龙井市| 徐水县| 土默特左旗| 江陵县| 铁力市| 体育| 徐闻县| 乐昌市| 鹤壁市| 德州市| 上虞市| 山阳县| 永州市| 泰顺县| 乌鲁木齐市| 芜湖市| 黎城县| 丹棱县| 侯马市| 奉节县| 油尖旺区| 陇西县| 苍山县| 临沧市| 永寿县| 呼伦贝尔市| 乳山市| 封丘县| 西林县| 嘉定区| 元阳县| 望都县| 蒙城县| 岳池县| 普定县| 镇坪县| 永宁县| 西和县| 聂拉木县|