- 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.
推薦閱讀
- Getting Started with Citrix XenApp? 7.6
- ServiceNow Application Development
- JavaScript前端開發(fā)模塊化教程
- JavaScript修煉之道
- PHP 7底層設(shè)計與源碼實現(xiàn)
- Vue.js快跑:構(gòu)建觸手可及的高性能Web應(yīng)用
- Java性能權(quán)威指南(第2版)
- 組態(tài)軟件技術(shù)與應(yīng)用
- Mastering ROS for Robotics Programming
- Mastering ArcGIS Enterprise Administration
- Rust游戲開發(fā)實戰(zhàn)
- Serverless Web Applications with React and Firebase
- Webpack實戰(zhàn):入門、進階與調(diào)優(yōu)(第2版)
- Python趣味編程與精彩實例
- Java Hibernate Cookbook