Skip to content

Instantly share code, notes, and snippets.

@fakenickels
Created April 11, 2017 13:17
Show Gist options
  • Save fakenickels/586def2e4e69a8119d3eb848cbb4f77c to your computer and use it in GitHub Desktop.
Save fakenickels/586def2e4e69a8119d3eb848cbb4f77c to your computer and use it in GitHub Desktop.
Immutability breakthroughs

But returning a new structure everytime it changes isn't slow?

It is in normal cases for JS objects and arrays but immutable data structures are reused "tries" so data is shared across all instances and persistence isn't affected. Tries are crazily efficient and basic all operations (insert, update, delete) resume to an O(1) op.

Comparison

Immutable data equality check is much faster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment