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
高速開発のためのコード整理術
sutetotanuki
1
390
AI巻き込み型コードレビューのススメ
nealle
0
110
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
140
Fragmented Architectures
denyspoltorak
0
150
Package Management Learnings from Homebrew
mikemcquaid
0
200
Oxlint JS plugins
kazupon
1
680
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
1.1k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
490
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
Grafana:建立系統全知視角的捷徑
blueswen
0
320
AI Schema Enrichment for your Oracle AI Database
thatjeffsmith
0
250
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
640
Featured
See All Featured
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
54
The browser strikes back
jonoalderson
0
360
BBQ
matthewcrist
89
10k
Leo the Paperboy
mayatellez
4
1.4k
How to Talk to Developers About Accessibility
jct
2
130
Building Applications with DynamoDB
mza
96
6.9k
SEO for Brand Visibility & Recognition
aleyda
0
4.2k
Paper Plane (Part 1)
katiecoart
PRO
0
4k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
670
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
90
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
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