- 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.
推薦閱讀
- Go語言高效編程:原理、可觀測性與優化
- Web交互界面設計與制作(微課版)
- Java應用開發與實踐
- Java FX應用開發教程
- 精通軟件性能測試與LoadRunner實戰(第2版)
- Mastering Yii
- Unity 3D腳本編程:使用C#語言開發跨平臺游戲
- Java EE 7 Development with WildFly
- Dart:Scalable Application Development
- C語言程序設計
- R語言與網站分析
- 熱處理常見缺陷分析與解決方案
- Flink原理深入與編程實戰:Scala+Java(微課視頻版)
- Developing RESTful Web Services with Jersey 2.0
- Learning Ext JS(Fourth Edition)