~/talk

The Immutable Way: A Guide to Cleaner, More Predictable JavaScript

Talkat XtremeJS 2024 · 2024-11-12..11-13· [javascript]
slides:none on file

Explains why shallow copies via the ES6 spread cause hidden shared references and shows structuredClone as the deep-clone fix; demonstrates how mutating the products array in a React shopping-cart adds a pound sign per render (four renders produced four symbols) and breaks numeric totals; introduces native immutability tools Object.freeze and Object.seal and the ES2023 array helpers like toSorted/toSpliced to return new arrays instead of mutating originals; builds a small React demo and fixes it by keeping state immutable.

AI-written summary · about

  1. 0:00Immutability in JavaScript
  2. 1:03Why immutability matters
  3. 2:48Mutability vs const
  4. 6:02Immutable copies with spread
  5. 8:08Shallow copy pitfalls
  6. 11:02Deep cloning with structuredClone
  7. 12:26Freezing and sealing objects
  8. 15:37Mutable state issues example
  9. 18:50Fixing state in React
  10. 20:58Immutability with arrays
  11. 23:23ES2023 immutable arrays
  12. 27:16Immutable libraries overview
  13. 28:19Conclusion
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.