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
950
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
Pull-Requestの内容を1クリックで動作確認可能にするワークフロー
natmark
2
450
CSC305 Lecture 01
javiergs
PRO
1
400
GraphQL×Railsアプリのデータベース負荷分散 - 月間3,000万人利用サービスを無停止で
koxya
1
1.1k
Your Perfect Project Setup for Angular @BASTA! 2025 in Mainz
manfredsteyer
PRO
0
120
CSC305 Lecture 04
javiergs
PRO
0
250
Railsだからできる 例外業務に禍根を残さない 設定設計パターン
ei_ei_eiichi
0
190
アメ車でサンノゼを走ってきたよ!
s_shimotori
0
140
ソフトウェア設計の実践的な考え方
masuda220
PRO
3
470
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
170
uniqueパッケージの内部実装を支えるweak pointerの話
magavel
0
920
開発生産性を上げるための生成AI活用術
starfish719
1
170
フロントエンド開発に役立つクライアントプログラム共通のノウハウ / Universal client-side programming best practices for frontend development
nrslib
7
3.9k
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
185
22k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
36
2.5k
Building a Modern Day E-commerce SEO Strategy
aleyda
43
7.7k
Making Projects Easy
brettharned
119
6.4k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
51k
YesSQL, Process and Tooling at Scale
rocio
173
14k
The Power of CSS Pseudo Elements
geoffreycrofte
79
6k
jQuery: Nuts, Bolts and Bling
dougneiner
64
7.9k
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Six Lessons from altMBA
skipperchong
28
4k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
2.6k
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