$30 off During Our Annual Pro Sale. View Details »
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
960
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
FluorTracer / RayTracingCamp11
kugimasa
0
230
チームをチームにするEM
hitode909
0
330
ゲームの物理 剛体編
fadis
0
350
20251127_ぼっちのための懇親会対策会議
kokamoto01_metaps
2
430
AIコーディングエージェント(NotebookLM)
kondai24
0
190
マスタデータ問題、マイクロサービスでどう解くか
kts
0
100
これならできる!個人開発のすゝめ
tinykitten
PRO
0
110
Developing static sites with Ruby
okuramasafumi
0
290
tparseでgo testの出力を見やすくする
utgwkk
2
220
Why Kotlin? 電子カルテを Kotlin で開発する理由 / Why Kotlin? at Henry
agatan
2
7.2k
AIコーディングエージェント(Gemini)
kondai24
0
220
Cap'n Webについて
yusukebe
0
130
Featured
See All Featured
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Six Lessons from altMBA
skipperchong
29
4.1k
Git: the NoSQL Database
bkeepers
PRO
432
66k
Making the Leap to Tech Lead
cromwellryan
135
9.7k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Statistics for Hackers
jakevdp
799
230k
How GitHub (no longer) Works
holman
316
140k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
70k
BBQ
matthewcrist
89
9.9k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
Rails Girls Zürich Keynote
gr2m
95
14k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.8k
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