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
300
Railsgirls: Where did my HTML and CSS go
bjelli
0
510
Berufe im World Wide Web
bjelli
0
210
Teach (all the) Rails
bjelli
0
440
Ruby One-Liners
bjelli
1
330
Other Decks in Programming
See All in Programming
GoとPHPのインターフェイスの違い
shimabox
2
190
CSS Linter による Baseline サポートの仕組み
ryo_manba
1
100
Honoのおもしろいミドルウェアをみてみよう
yusukebe
1
210
ファインディの テックブログ爆誕までの軌跡
starfish719
2
1.1k
Amazon S3 TablesとAmazon S3 Metadataを触ってみた / 20250201-jawsug-tochigi-s3tables-s3metadata
kasacchiful
0
160
プログラミング言語学習のススメ / why-do-i-learn-programming-language
yashi8484
0
130
仕様変更に耐えるための"今の"DRY原則を考える / Rethinking the "Don't repeat yourself" for resilience to specification changes
mkmk884
0
170
sappoRo.R #12 初心者セッション
kosugitti
0
250
Introduction to kotlinx.rpc
arawn
0
700
データの整合性を保つ非同期処理アーキテクチャパターン / Async Architecture Patterns
mokuo
47
17k
2024年のkintone API振り返りと2025年 / kintone API look back in 2024
tasshi
0
220
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
190
Featured
See All Featured
How GitHub (no longer) Works
holman
314
140k
Facilitating Awesome Meetings
lara
52
6.2k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.3k
StorybookのUI Testing Handbookを読んだ
zakiyama
28
5.5k
Being A Developer After 40
akosma
89
590k
Designing for humans not robots
tammielis
250
25k
Automating Front-end Workflow
addyosmani
1368
200k
Music & Morning Musume
bryan
46
6.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Embracing the Ebb and Flow
colly
84
4.6k
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