Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JavaScript Closures
Search
Lean Machine
September 04, 2013
Programming
1
1.1k
JavaScript Closures
Lean Machine
September 04, 2013
Tweet
Share
More Decks by Lean Machine
See All by Lean Machine
Graceful Degradation with Modernizr
leanmachine
1
1k
Intro to HTML5
leanmachine
3
980
Organizing Stylesheets with CSS Pre-processors
leanmachine
2
950
Responsive Web Design in a Nutshell
leanmachine
3
130
Seven UX Design Rules
leanmachine
9
1k
JavaScript Inheritance
leanmachine
2
1.1k
Asynchronous JavaScript
leanmachine
1
960
JavaScript Promises
leanmachine
2
1.1k
Other Decks in Programming
See All in Programming
AI時代のドメイン駆動設計-DDD実践におけるAI活用のあり方 / ddd-in-ai-era
minodriven
23
9k
なぜ今、Terraformの本を書いたのか? - 著者陣に聞く!『Terraformではじめる実践IaC』登壇資料
fufuhu
4
660
TDD 実践ミニトーク
contour_gara
0
150
tool ディレクティブを導入してみた感想
sgash708
1
150
SOCI Index Manifest v2が出たので調べてみた / Introduction to SOCI Index Manifest v2
tkikuc
1
110
ワープロって実は計算機で
pepepper
2
1.4k
あなたとJIT, 今すぐアセンブ ル
sisshiki1969
1
730
AWS Serverless Application Model入門_20250708
smatsuzaki
0
130
ゲームの物理
fadis
5
1.5k
RDoc meets YARD
okuramasafumi
2
130
[FEConf 2025] 모노레포 절망편, 14개 레포로 부활하기까지 걸린 1년
mmmaxkim
0
1k
パスタの技術
yusukebe
1
400
Featured
See All Featured
Speed Design
sergeychernyshev
32
1.1k
Art, The Web, and Tiny UX
lynnandtonic
302
21k
Visualization
eitanlees
147
16k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
48
9.6k
Statistics for Hackers
jakevdp
799
220k
What’s in a name? Adding method to the madness
productmarketing
PRO
23
3.6k
How to Ace a Technical Interview
jacobian
279
23k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
30
9.6k
4 Signs Your Business is Dying
shpigford
184
22k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Raft: Consensus for Rubyists
vanstee
140
7.1k
Designing for humans not robots
tammielis
253
25k
Transcript
for ( var i=0; i<5; i++ ) { // Wait
i seconds then print // the number of seconds waited for each i }
for ( var i=0; i<5; i++ ) { // Wait
i seconds then print // the number of seconds waited for each i }
JavaScript Closures Get comfortable leanmachine.se ▪
[email protected]
▪ 2013-09-06
Server JavaScript allows you to refer to variables that were
defined outside of the current function Functions can refer to variables defined in outer functions, even a!er those functions have returned Closures can update the values of outer variables Three rules of closures
console.log(generateUnique()); console.log(generateUnique()); console.log(generateUnique());
What does the scope chain look like?
It can be inspected in browser dev tools
Bonus The with-keyword
leanmachine.se ▪
[email protected]
▪ 2013-09-06