JavaScript Immutability - "Don't Go Changing"
summary
Compares plain ES6 copying versus libraries and recommends Immutable.js (Facebook) which implements persistent data structures (HAMT / index trees) to create efficient new versions that share memory. Shows concrete API: create with fromJS, read with get/getIn, change with set/update, bulk-change with withMutations, convert back with toJS; lists behave like immutable arrays and sequences support lazy ranges. Reports small CPU and memory overhead versus big gains in fast reference equality checks, easier undo stacks, and safe caching.
AI-written summary · about
chapters (17)
- 0:00Introduction
- 1:26What is immutability
- 2:28Persistent data structures
- 4:55Directed acyclic graphs
- 5:16Index trees for arrays
- 9:07Hash array mapped trees
- 13:21Benefits of immutability
- 16:08Drawbacks in JavaScript
- 17:10Options for immutability
- 21:26Manual immutability with ES6
- 23:51Immutable.js library
- 27:42Working with Immutable.js maps
- 33:20Batch changes with withMutations
- 34:24Immutable.js lists
- 38:17Sequences and infinite collections
- 41:47Summary
- 43:11Q&A
related talks
19mImmutability is Changing: From Immutable.js to Immer
33mImmutable data structures for functional JS
29mThe Immutable Way: A Guide to Cleaner, More Predictable JavaScript
31mImmutable Data and React
27mImmutable data structures for functional JS
30mImmer, Immutability and the Wonderful World of Proxies
26mImmutability, interactivity & JavaScript
34mFunctional Programming in JavaScript
