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
bjelli
July 18, 2012
Programming
3
880
Javascript Closures
a short introduction (in javascript + german)
bjelli
July 18, 2012
Tweet
Share
More Decks by bjelli
See All by bjelli
Intro to Web- and Mobile-Developement
bjelli
0
310
Railsgirls: Where did my HTML and CSS go
bjelli
0
530
Berufe im World Wide Web
bjelli
0
220
Teach (all the) Rails
bjelli
0
440
Ruby One-Liners
bjelli
1
330
Other Decks in Programming
See All in Programming
「理解」を重視したAI活用開発
fast_doctor
0
120
AWS で実現する安全な AI エージェントの作り方 〜 Bedrock Engineer の実装例を添えて 〜 / how-to-build-secure-ai-agents
gawa
8
830
Agentic Applications with Symfony
el_stoffel
2
310
国漢文混用体からHolloまで
minhee
1
190
The Nature of Complexity in John Ousterhout’s Philosophy of Software Design
philipschwarz
PRO
0
120
AI Coding Agent Enablement - エージェントを自走させよう
yukukotani
14
6.1k
Sharing features among Android applications: experience feedback
jbvincey
0
110
設計の本質:コード、システム、そして組織へ / The Essence of Design: To Code, Systems, and Organizations
nrslib
4
600
プロダクト横断分析に役立つ、事前集計しないサマリーテーブル設計
hanon52_
2
450
AIコーディングの理想と現実
tomohisa
23
31k
ComposeでWebアプリを作る技術
tbsten
0
110
Golangci-lint v2爆誕: 君たちはどうすべきか
logica0419
1
130
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
13
1.4k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
30
2k
Fantastic passwords and where to find them - at NoRuKo
philnash
51
3.1k
Designing Experiences People Love
moore
141
24k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
26k
Docker and Python
trallard
44
3.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.8k
It's Worth the Effort
3n
184
28k
The Cult of Friendly URLs
andyhume
78
6.3k
Transcript
Javascript Closures
function r1( s, x ) { var result = "";
while( x ) { result += s; x--; } return s; } http://jsfiddle.net/bjelline/54dRs/ Funktionen in JS
r2 = function ( s, x ) { var result
= ""; while( x ) { result += s; x--; } return result; } http://jsfiddle.net/bjelline/54dRs/ Funktionen in JS
etwas, das als Übergabeparameter oder Rückgabewert einer Funktion oder Prozedur
auftritt bzw. einer Variable zugewiesen werden kann. Functions as first class citizens...
function mk_function() { return function() { return "Rückgabewert"; }; }
f = mk_function(); f(); g = f; Funktionen in JS
function mk_function() { var a = 42; return function() {
return "Rückgabewert ist " + a; }; } f = mk_function(); f(); innere Funktionen + vars
function mk_sammler() { var gesammelt = ""; return function(s) {
gesammelt += s; return gesammelt; }; } f = mk_sammler(); http://jsfiddle.net/bjelline/jhqbq/ innere Funktionen + vars
Für die Funktion bleibt auch die Variable erhalten Closure