$30 off During Our Annual Pro Sale. View Details »
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
290
Railsgirls: Where did my HTML and CSS go
bjelli
0
500
Berufe im World Wide Web
bjelli
0
200
Teach (all the) Rails
bjelli
0
430
Ruby One-Liners
bjelli
1
330
Other Decks in Programming
See All in Programming
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
3.8k
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
1
230
Missing parts when designing and implementing Android UI
ericksli
0
390
Criando Commits Incríveis no Git
marcelgsantos
2
150
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
130
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
130
ブラウザ単体でmp4書き出すまで - muddy-web - 2024-12
yue4u
0
100
layerx_20241129.pdf
kyoheig3
2
260
暇に任せてProxmoxコンソール 作ってみました
karugamo
1
450
Full stack testing :: basic to basic
up1
1
890
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
300
React CompilerとFine Grained Reactivityと宣言的UIのこれから / The next chapter of declarative UI
ssssota
7
3.5k
Featured
See All Featured
It's Worth the Effort
3n
183
27k
Designing for humans not robots
tammielis
250
25k
The Invisible Side of Design
smashingmag
298
50k
How to Ace a Technical Interview
jacobian
276
23k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Bash Introduction
62gerente
608
210k
Fashionably flexible responsive web design (full day workshop)
malarkey
405
65k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
BBQ
matthewcrist
85
9.3k
Documentation Writing (for coders)
carmenintech
65
4.5k
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