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
はじめてのDSPy - 言語モデルを『プロンプト』ではなく『プログラミング』するための仕組み
masahiro_nishimi
4
16k
O Que É e Como Funciona o PHP-FPM?
marcelgsantos
0
210
Foundation Modelsを実装日本語学習アプリを作ってみた!
hypebeans
0
130
実践Claude Code:20の失敗から学ぶAIペアプログラミング
takedatakashi
18
8.9k
Ktorで簡単AIアプリケーション
tsukakei
0
110
開発組織の戦略的な役割と 設計スキル向上の効果
masuda220
PRO
10
1.7k
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
520
Six and a half ridiculous things to do with Quarkus
hollycummins
0
220
AI 駆動開発におけるコミュニティと AWS CDK の価値
konokenj
5
280
Building, Deploying, and Monitoring Ruby Web Applications with Falcon (Kaigi on Rails 2025)
ioquatix
4
2.5k
モテるデスク環境
mozumasu
3
1.3k
Android16 Migration Stories ~Building a Pattern for Android OS upgrades~
reoandroider
0
140
Featured
See All Featured
Speed Design
sergeychernyshev
32
1.2k
Intergalactic Javascript Robots from Outer Space
tanoku
272
27k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.1k
The Cost Of JavaScript in 2023
addyosmani
55
9.1k
Mobile First: as difficult as doing things right
swwweet
225
10k
Build your cross-platform service in a week with App Engine
jlugia
233
18k
The Pragmatic Product Professional
lauravandoore
36
7k
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Optimizing for Happiness
mojombo
379
70k
Optimising Largest Contentful Paint
csswizardry
37
3.5k
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