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.1k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
JavaScript Closures
Lean Machine
September 04, 2013
More Decks by Lean Machine
See All by Lean Machine
Graceful Degradation with Modernizr
leanmachine
1
1k
Intro to HTML5
leanmachine
3
990
Organizing Stylesheets with CSS Pre-processors
leanmachine
2
960
Responsive Web Design in a Nutshell
leanmachine
3
140
Seven UX Design Rules
leanmachine
9
1k
JavaScript Inheritance
leanmachine
2
1.1k
Asynchronous JavaScript
leanmachine
1
970
JavaScript Promises
leanmachine
2
1.1k
Other Decks in Programming
See All in Programming
Oxlintのカスタムルールの現況
syumai
6
1.1k
LLMによるContent Moderationの本番運用の裏側と品質担保への挑戦
suikabar
2
630
net-httpのHTTP/2対応について
naruse
0
480
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.5k
RTSPクライアントを自作してみた話
simotin13
0
600
Contextとはなにか
chiroruxx
1
310
PHPで使える日時の表現と、その知り方 #frontend_phpcon_do
o0h
PRO
0
230
dRuby over BLE
makicamel
2
330
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
280
さぁV100、メモリをお食べ・・・
nilpe
0
140
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
330
Signal Forms: Beyond the Basics @ngBaguette 2026 in Paris
manfredsteyer
PRO
0
250
Featured
See All Featured
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
150
Discover your Explorer Soul
emna__ayadi
2
1.1k
Everyday Curiosity
cassininazir
0
230
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
480
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.4k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
170
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
160
Claude Code のすすめ
schroneko
67
230k
The World Runs on Bad Software
bkeepers
PRO
72
12k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
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