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
970
Organizing Stylesheets with CSS Pre-processors
leanmachine
2
950
Responsive Web Design in a Nutshell
leanmachine
3
120
Seven UX Design Rules
leanmachine
9
1k
JavaScript Inheritance
leanmachine
2
1.1k
Asynchronous JavaScript
leanmachine
1
950
JavaScript Promises
leanmachine
2
1.1k
Other Decks in Programming
See All in Programming
Data Contracts In Practice With Debezium and Apache Flink (Kafka Summit London)
gunnarmorling
2
270
LLMチャットボットのアプリケーション設計Tips
os1ma
4
650
Deno に Web 標準 API を実装する / Implementing Web Standard API to Deno
petamoriken
0
350
WasmOS: Wasmを実行する自作Microkernel
riru
0
370
とにかくHTTP3をライトニングに話す / Anyway, I'll talk to Lightning about HTTP3.
seike460
PRO
0
120
【KMC春合宿2024】実装視点で見るNeural Radiance Fields
runningoutrate
0
150
フロントエンドパフォーマンス 入門
shouta2
7
1.5k
Enhancing Applications with Accessibility API
kishikawakatsumi
3
820
DocC Tutorial と TCA におけるテスト機能の紹介
kalupas226
1
330
LPIXEL×CADDi_kaerururu
kaerururu
3
300
品質が高いコードって何?Rev2.1
ickx
1
490
DDD, necessary but insufficient: physical design principles for microservices
cer
PRO
0
2.1k
Featured
See All Featured
We Have a Design System, Now What?
morganepeng
42
6.7k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
8
8.2k
Adopting Sorbet at Scale
ufuk
66
8.5k
Building a Scalable Design System with Sketch
lauravandoore
455
32k
Building Applications with DynamoDB
mza
88
5.6k
Music & Morning Musume
bryan
39
5.5k
10 Git Anti Patterns You Should be Aware of
lemiorhan
644
57k
Designing on Purpose - Digital PM Summit 2013
jponch
109
6.4k
Making Projects Easy
brettharned
106
5.4k
The Straight Up "How To Draw Better" Workshop
denniskardys
227
130k
Robots, Beer and Maslow
schacon
PRO
154
7.9k
Debugging Ruby Performance
tmm1
68
11k
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