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

  • 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.
主站蜘蛛池模板: 中方县| 荃湾区| 彝良县| 平泉县| 天峻县| 古丈县| 潜山县| 抚宁县| 荃湾区| 苍南县| 麦盖提县| 朔州市| 罗定市| 育儿| 增城市| 丹寨县| 宝山区| 德江县| 南涧| 平泉县| 颍上县| 瑞金市| 宜君县| 高邑县| 正镶白旗| 缙云县| 宿州市| 焉耆| 拉萨市| 南阳市| 大荔县| 普兰店市| 合肥市| 通江县| 河南省| 凉山| 开平市| 全南县| 翁源县| 西青区| 通榆县|