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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
bjelli
July 18, 2012
Programming
900
3
Share
Javascript Closures
a short introduction (in javascript + german)
bjelli
July 18, 2012
More Decks by bjelli
See All by bjelli
Intro to Web- and Mobile-Developement
bjelli
0
320
Railsgirls: Where did my HTML and CSS go
bjelli
0
600
Berufe im World Wide Web
bjelli
0
270
Teach (all the) Rails
bjelli
0
450
Ruby One-Liners
bjelli
1
350
Other Decks in Programming
See All in Programming
DynamoDBには集計系のクエリがないけどなんとかしたい
musan
1
120
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
2
190
ReactとSvelteのその先、Ripple-TS / Beyond React and Svelte: Ripple-TS
ssssota
3
1.9k
LLM Plugin for Node-REDの利用方法と開発について
404background
0
150
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
2
520
dRuby over BLE
makicamel
1
270
inferと仲良くなる10分間
ryokatsuse
1
330
RTSPクライアントを自作してみた話
simotin13
0
410
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
110
TSKaigi2026-静的解析への投資がAI時代のコード品質を支える ── カスタムESLintルールの設計と運用
hayatokudou
7
1.3k
AI駆動開発で崩れていくコードベースを立て直す
kyoko_nr_nr
1
410
Old Dog, New Tricks: The Java 25 Reinvention - JNation
bazlur_rahman
0
140
Featured
See All Featured
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
830
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
330
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
390
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
210
Product Roadmaps are Hard
iamctodd
PRO
55
12k
Thoughts on Productivity
jonyablonski
76
5.2k
A Soul's Torment
seathinner
6
2.9k
Building Flexible Design Systems
yeseniaperezcruz
330
40k
The Cult of Friendly URLs
andyhume
79
6.9k
Balancing Empowerment & Direction
lara
6
1.1k
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