- Mastering Immutable.js
- Adam Boduch
- 138字
- 2021-07-08 10:30:10
Chaining value insertion methods
When you need to insert more than one value into a collection, you have to call push() or set() multiple times. Instead of storing the new collection every time that you call the method, you can chain the method calls together. You can store the result of this chained call, which is the last collection. The other collections are called intermediary collections, which are freed the next time the garbage collector runs.
Immutable.js can copy collections efficiently because it only copies the parts of the collection that it absolutely needs to copy. When you make persistent changes, most of the old collection data is shared with the new collection. It can do this because most of the collection data hasn't changed, so it would be wasteful just to throw it to the garbage collector.
推薦閱讀
- Advanced Splunk
- Deploying Node.js
- Learning ROS for Robotics Programming(Second Edition)
- 控糖控脂健康餐
- 精通軟件性能測試與LoadRunner實戰(第2版)
- Getting Started with SQL Server 2012 Cube Development
- Java EE 7 Development with NetBeans 8
- 零基礎學Python數據分析(升級版)
- Learning OpenStack Networking(Neutron)(Second Edition)
- Learning PHP 7
- Linux Shell核心編程指南
- C/C++數據結構與算法速學速用大辭典
- Python Data Science Cookbook
- Visual Basic程序設計(第三版)
- 深入分析GCC