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
890
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
320
Railsgirls: Where did my HTML and CSS go
bjelli
0
560
Berufe im World Wide Web
bjelli
0
250
Teach (all the) Rails
bjelli
0
440
Ruby One-Liners
bjelli
1
340
Other Decks in Programming
See All in Programming
CSC509 Lecture 11
javiergs
PRO
0
280
Reactive Thinking with Signals and the Resource API
manfredsteyer
PRO
0
120
CSC509 Lecture 09
javiergs
PRO
0
280
Designing Repeatable Edits: The Architecture of . in Vim
satorunooshie
0
220
HTTPじゃ遅すぎる! SwitchBotを自作ハブで動かして学ぶBLE通信
occhi
0
160
Blazing Fast UI Development with Compose Hot Reload (Bangladesh KUG, October 2025)
zsmb
2
450
Blazing Fast UI Development with Compose Hot Reload (droidcon London 2025)
zsmb
0
440
フロントエンド開発のためのブラウザ組み込みAI入門
masashi
7
3.7k
Swift Concurrency 年表クイズ
omochi
3
220
Webサーバーサイド言語としてのRustについて
kouyuume
1
5k
NIKKEI Tech Talk#38
cipepser
0
360
Pythonに漸進的に型をつける
nealle
1
150
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
132
19k
Being A Developer After 40
akosma
91
590k
How GitHub (no longer) Works
holman
315
140k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
22k
The World Runs on Bad Software
bkeepers
PRO
72
11k
Building a Modern Day E-commerce SEO Strategy
aleyda
44
8k
Designing for humans not robots
tammielis
254
26k
What's in a price? How to price your products and services
michaelherold
246
12k
Facilitating Awesome Meetings
lara
57
6.6k
Designing Experiences People Love
moore
142
24k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
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