Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Practically Immutable
Search
sporto
March 28, 2015
Technology
220
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Practically Immutable
Immutable data in practice in JavaScript
sporto
March 28, 2015
More Decks by sporto
See All by sporto
React inside Elm
sporto
2
200
Elm
sporto
1
300
Redux: Flux Reduced
sporto
1
390
Webpack and React
sporto
4
410
Rails with Webpack
sporto
1
250
Lesson learnt building Single Page Application
sporto
0
150
Grunt
sporto
1
220
Safe Testing in Ruby
sporto
1
150
Go - A great language for building web applications
sporto
1
370
Other Decks in Technology
See All in Technology
Reactの設計論
uhyo
24
13k
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
3
3k
え、こんなに早く改修できるの?──新人エンジニアとスクラムマスターの2人が語る、AI×アジャイル開発の現場
ysasago
0
130
Screen Lens - 今見てる画面を翻訳する
komagata
0
310
事業課題から技術的負債に向き合う
sansantech
PRO
2
1.9k
HRC_Frontend_Conference_Fukuoka_2026.pdf
ts020
0
730
「守り」で活用するオンデバイスLLM 〜写ってはいけないを総力戦で防ぐ〜 / iOSDC Japan 2026
nakamuuu
0
160
【技術的負債conf】事業成長に伴う技術的負債の説明責任とAIによるモニタリング、認知的負債について
i35_267
2
1.6k
俺の仕事は AIに奪われないし、たぶんその BIも要らない
hikaruri
0
490
DEFCON34-Write-up_HYCu-MYCu
daikiokazaki
0
160
AIに任せた品質は、誰が見立てるのか - AI時代のテストマネジメント
nakanao
2
810
負債のメタファと2026年 / Debt Metaphor in Agentic Engineering Age 202609 Edition
twada
PRO
8
3.1k
Featured
See All Featured
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
430
Tell your own story through comics
letsgokoyo
1
1.1k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
910
Design in an AI World
tapps
1
320
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
330
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
520
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Color Theory Basics | Prateek | Gurzu
gurzu
1
470
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
500
The browser strikes back
jonoalderson
0
1.7k
Transcript
practically immutable ! Immutable data in JS @sebasporto
I build CRUD apps, mostly
What? • Something that cannot change • Once created stays
the same
var array1 = [1, 2].immutable var array2 = array1.push(3) !
array1 //=> [1, 2] array2 //=> [1, 2, 3]
WHY?
# 1 no side effects
var orders = [1, 2]; processOrders(orders); what is orders after
this?
Predictability Store Comp Comp Data Data wants to sort data
wants to transform data doesn't want its data to be modified externally
Enforces uni directional data flow React + Flux Store Comp
Action
# 2 Easier workflows
Undo add(item) { history.push(items) items = items.push(item) } undo() {
items = history.pop() }
Dirty objects Get record from store Clone record Edit record
Save Replace original Yes Discard No
Dirty objects Get record from store Edit record Save Replace
original Yes Discard No
HOW?
clojurescript immutable data for free but this talk is about
plain JS
• In JS strings and numbers are immutable (not the
case in every language) • Arrays, objects are not - so we need help here • JS and immutable data => opposing forces
immutable.js • Great for simple collections • [1, 2, ...]
['a', 'b' ...] • Caveats for collections with objects https://github.com/facebook/immutable-js
Immutable.js var record = {label: 'Sam'}; var list = Immutable.List([record]);
! console.log(list.get(0).label) // => 'Sam' http://jsbin.com/dilupu/1/embed?js,console record.label = 'Biff' ! console.log(list.get(0).label) // => 'Biff' Opps!
immutable.js To be fair: Immutable.js can do the right thing
if you learn it really well Immutable.js != Just works™
Seamless immutable • Fixes Immutable.js issues with deep objects https://github.com/rtfeldman/seamless-immutable
var record = {label: 'Sam'}; var list = Immutable([record]); !
console.log(list[0].label) // => 'Sam' ! record.label = 'Biff' ! console.log(list[0].label) // => 'Sam' http://jsbin.com/fayupu/1/edit?js,console Seamless immutable
imm https://github.com/sporto/imm • Build on top of seamless-immutable • Nice
CRUD API
imm list = list.add(record) list = list.replace(record) list = list.remove(id)
! record = list.get(id)
in Conclusion
Immutable data can make your application more robust
but play a lot with your chosen lib, understand
the caveats
Thanks