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
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
Rubyで鍛える仕組み化プロヂュース力
muryoimpl
0
260
The Art of Re-Architecture - Droidcon India 2025
siddroid
0
150
Navigating Dependency Injection with Metro
l2hyunwoo
1
200
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
160
マスタデータ問題、マイクロサービスでどう解くか
kts
0
170
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
450
Go コードベースの構成と AI コンテキスト定義
andpad
0
150
AIエージェントの設計で注意するべきポイント6選
har1101
6
2.8k
tparseでgo testの出力を見やすくする
utgwkk
2
330
tsgolintはいかにしてtypescript-goの非公開APIを呼び出しているのか
syumai
7
2.4k
これならできる!個人開発のすゝめ
tinykitten
PRO
0
140
Context is King? 〜Verifiability時代とコンテキスト設計 / Beyond "Context is King"
rkaga
10
1.5k
Featured
See All Featured
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
115
100k
Done Done
chrislema
186
16k
Claude Code のすすめ
schroneko
67
210k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
Building AI with AI
inesmontani
PRO
1
600
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
43
Agile Leadership in an Agile Organization
kimpetersen
PRO
0
64
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
GraphQLの誤解/rethinking-graphql
sonatard
74
11k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
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