- 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.
推薦閱讀
- Clojure Programming Cookbook
- 零基礎(chǔ)搭建量化投資系統(tǒng):以Python為工具
- Android Application Development Cookbook(Second Edition)
- Mastering AndEngine Game Development
- Bootstrap for Rails
- Angular應(yīng)用程序開(kāi)發(fā)指南
- OpenMP核心技術(shù)指南
- 30天學(xué)通C#項(xiàng)目案例開(kāi)發(fā)
- Java Web動(dòng)態(tài)網(wǎng)站開(kāi)發(fā)(第2版·微課版)
- Bitcoin Essentials
- Pandas 1.x Cookbook
- Swift 2 Design Patterns
- Learning Gerrit Code Review
- Python AI游戲編程入門(mén):基于Pygame和PyTorch
- Mastering High Performance with Kotlin