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
870
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
280
Railsgirls: Where did my HTML and CSS go
bjelli
0
460
Berufe im World Wide Web
bjelli
0
180
Teach (all the) Rails
bjelli
0
430
Ruby One-Liners
bjelli
1
330
Other Decks in Programming
See All in Programming
Rubyのパフォーマンスプロファイリングの改善 / Enhancing performance profiling for Ruby
osyoyu
1
410
生成AIをkintoneに連携してみた
hideg
0
230
わかりやすい正解を捨てて、コトに向き合う - スクラムフェス金沢2024 スポンサーセッション
yusukekokubo
0
170
「2024年版 Kotlin サーバーサイドプログラミング実践開発」の補講 〜O/Rマッパー編〜
n_takehata
2
260
英語
s_shimotori
1
220
ドメイン駆動設計の実践
masuda220
PRO
17
5.1k
CSC307 Lecture 14
javiergs
PRO
0
220
CSC307 Lecture 13
javiergs
PRO
0
150
Harnessing Large Language Models for Training-free Video Anomaly Detection
tereka114
1
1.3k
From Spring Boot 2 to Spring Boot 3 with Java 22 and Jakarta EE
ivargrimstad
0
1.9k
Introduction of Happy Eyeballs Version 2 (RFC8305) to the Socket library
coe401_
1
220
大規模マルチテナントを解決するYugabyteDBという選択肢
nnaka2992
1
250
Featured
See All Featured
Fireside Chat
paigeccino
25
2.8k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
17
1.5k
VelocityConf: Rendering Performance Case Studies
addyosmani
321
23k
Side Projects
sachag
451
42k
Building a Scalable Design System with Sketch
lauravandoore
458
32k
Facilitating Awesome Meetings
lara
46
5.8k
We Have a Design System, Now What?
morganepeng
46
7k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
20
7.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
228
16k
Optimising Largest Contentful Paint
csswizardry
18
2.6k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.9k
Building Applications with DynamoDB
mza
89
5.8k
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