Immutable.js学习笔记(一)----- Immutable简介
作者:互联网
一、Immutable.js 介绍
Immutable.js 官方文档 : https://immutable-js.github.io/immutable-js/
关于Immutable的定义,官方文档是这样说的:
Immutable data cannot be changed once created, leading to much simpler application development, no defensive copying, and enabling advanced memoization and change detection techniques with simple logic. Persistent data presents a mutative API which does not update the data in-place, but instead always yields new updated data.
不可变的数据一经创建就无法更改,从而使应用程序开发更加简单,没有防御性的复制,并且可以使用简单的逻辑实现高级的记忆和更改检测技术。持久数据提供了一个变异的API,它不会就地更新数据,而是总是生成新的更新数据。
Immutable.js provides many Persistent Immutable data structures including: List, Stack, Map, OrderedMap, Set, OrderedSet and Record.
Immutable.js 提供许多持久不变的数据结构,包括:List、Stack、Map、OrderedMap、Set、OrderedSet和Record。
These data structures are highly efficient on modern JavaScript VMs by using structural sharing via hash maps tries and vector tries as popularized by Clojure and Scala, minimizing the need to copy or cache data.
这些数据结构在现代JavaScript vm上是高效的,通过Clojure和Scala推广的hash-maps尝试和vector尝试使用结构共享,最大限度地减少了复制或缓存数据的需要
Immutable.js also provides a lazy Seq, allowing efficient chaining of collection methods like map and filter without creating intermediate representations. Create some Seq with Range and Repeat.
Immutable.js还提供了lazy Seq,允许高效地链接map和filter等收集方法,而无需创建中间表示。用范围和重复创建一些序列。
如图:
二、 Immutable.js 优点
栗子:
没有使用immutable.js
使用immutable.js
详情参考:Immutable 详解及 React 中实践
标签:Seq,immutable,maps,-----,js,data,Immutable 来源: https://blog.csdn.net/qq_45103612/article/details/115899623