Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
JavaScript Closures
Search
Lean Machine
September 04, 2013
Programming
1.1k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
JavaScript Closures
Lean Machine
September 04, 2013
Transcript
9 slides
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
More Decks by Lean Machine
See All by Lean Machine
Graceful Degradation with Modernizr
leanmachine
1
1.1k
Intro to HTML5
leanmachine
3
1k
Organizing Stylesheets with CSS Pre-processors
leanmachine
2
970
Responsive Web Design in a Nutshell
leanmachine
3
150
Seven UX Design Rules
leanmachine
9
1.1k
JavaScript Inheritance
leanmachine
2
1.1k
Asynchronous JavaScript
leanmachine
1
980
JavaScript Promises
leanmachine
2
1.1k
Other Decks in Programming
See All in Programming
Enforcing Your Architecture with Unit Tests in the AI Era (Swift Connection X)
steliosf
PRO
1
190
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
170
Skills Are the New npm [AAIF Bengaluru]
shivamsaraswat
0
120
疎結合とは何か?ソフトウェア設計における結合バランスについて考える #phpcon_niigata
kajitack
2
420
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
270
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
3
220
プロジェクトコードをキレイキレイしよう!暗黙的な参照を読み解く静的解析
ostk0069
0
220
Kotlin JVM用に作られたライブラリのKMPを前提とした再設計
jsoizo
0
230
高橋メソッドでCVE解説シリーズ 〜CVE-2026-112816〜
hakkadaikon
0
270
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
240
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
360
Featured
See All Featured
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.9k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.7k
Building Applications with DynamoDB
mza
96
7.3k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Crafting Experiences
bethany
1
460
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Skip the Path - Find Your Career Trail
mkilby
1
300
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
4
1.3k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
690
Building Adaptive Systems
keathley
44
3.3k
Writing Fast Ruby
sferik
630
63k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
22k