Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥
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
570
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
Full-Cycle Reactivity in Angular: SignalStore mit Signal Forms und Resources
manfredsteyer
PRO
0
180
関数実行の裏側では何が起きているのか?
minop1205
1
600
バックエンドエンジニアによる Amebaブログ K8s 基盤への CronJobの導入・運用経験
sunabig
0
140
【CA.ai #3】ワークフローから見直すAIエージェント — 必要な場面と“選ばない”判断
satoaoaka
0
220
全員アーキテクトで挑む、 巨大で高密度なドメインの紐解き方
agatan
8
19k
AIと協働し、イベントソーシングとアクターモデルで作る後悔しないアーキテクチャ Regret-Free Architecture with AI, Event Sourcing, and Actors
tomohisa
5
18k
ローターアクトEクラブ アメリカンナイト:川端 柚菜 氏(Japan O.K. ローターアクトEクラブ 会長):2720 Japan O.K. ロータリーEクラブ2025年12月1日卓話
2720japanoke
0
560
社内オペレーション改善のためのTypeScript / TSKaigi Hokuriku 2025
dachi023
1
500
テストやOSS開発に役立つSetup PHP Action
matsuo_atsushi
0
140
【CA.ai #3】Google ADKを活用したAI Agent開発と運用知見
harappa80
0
270
Microservices rules: What good looks like
cer
PRO
0
600
スタートアップを支える技術戦略と組織づくり
pospome
8
15k
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.3k
Scaling GitHub
holman
464
140k
It's Worth the Effort
3n
187
29k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
The Cult of Friendly URLs
andyhume
79
6.7k
Why You Should Never Use an ORM
jnunemaker
PRO
60
9.6k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.2k
Navigating Team Friction
lara
191
16k
Balancing Empowerment & Direction
lara
5
780
Building an army of robots
kneath
306
46k
Optimising Largest Contentful Paint
csswizardry
37
3.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