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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Lean Machine
September 04, 2013
Programming
1.1k
1
Share
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
SREに優しいTerraform構成 modulesとstateの組み方
hiyanger
2
170
第3木曜LT会 #28
tinykitten
PRO
0
120
Back to the roots of date
jinroq
0
700
Explore CoroutineScope
tomoeng11
0
160
20年以上続くプロダクトでも使い続けられる静的解析ツールを求めて
matsuo_atsushi
0
140
ソースコード→AST→オペコード、の旅を覗いてみる
o0h
PRO
1
120
継続的な負荷検証を目指して
pyama86
0
210
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
2.5k
実践ハーネスエンジニアリング:ステアリングループを実例から読み解く / Practical Harness Engineering: Understanding Steering Loops Through Real-World Examples
nrslib
4
3.1k
How We Benchmarked Quarkus: Patterns and anti-patterns
hollycummins
1
180
Road to RubyKaigi: Play Hard(ware)
makicamel
1
540
Programming with a DJ Controller — not vibe coding
m_seki
3
780
Featured
See All Featured
The Language of Interfaces
destraynor
162
26k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
SEO for Brand Visibility & Recognition
aleyda
0
4.5k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.3k
Building the Perfect Custom Keyboard
takai
2
750
Raft: Consensus for Rubyists
vanstee
141
7.4k
Side Projects
sachag
455
43k
ラッコキーワード サービス紹介資料
rakko
1
3.2M
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
10k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
450
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
200
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