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
850
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
240
Railsgirls: Where did my HTML and CSS go
bjelli
0
430
Berufe im World Wide Web
bjelli
0
180
Teach (all the) Rails
bjelli
0
430
Ruby One-Liners
bjelli
1
320
Other Decks in Programming
See All in Programming
両面どころかインフラもTSでできるよ ~ 全方位TypeScriptによるプロダクト開発 ~
myfinder
9
3.2k
ゆるい個人開発のススメ
kuroppe1819
10
940
Folding Cheat Sheet #2
philipschwarz
PRO
0
110
今の SmartHR にエンジニアで入社するとどうなるの?
daisukeshinoku
5
4.6k
PHPの次期バージョンはこの時期どうなっているのか - Internalsの開発体制について - PHPカンファレンス小田原
youkidearitai
PRO
1
180
[SF Ruby, March 2024] Rails on Wasm
palkan
0
380
コードレビューで学ぶ!Kotlinオブジェクト指向デザインパターン
akkie76
2
180
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
1
190
Blue/Greenデプロイの導入による 運用フローの改善
kudoas
1
350
Zero Waste, Radical Magic, and Italian Graft – Quarkus Efficiency Secrets
hollycummins
0
220
0→1と1→10の狭間で Javaという技術選定を振り返る/Reflecting on the Decision to Choose Java Between Scaling from 0 to 1 and 1 to 10
jaguar_imo
2
370
Java 22 Overview
kishida
1
170
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
36
2.5k
What the flash - Photography Introduction
edds
64
11k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
18
1.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
15
1.4k
Practical Orchestrator
shlominoach
181
9.7k
Music & Morning Musume
bryan
41
5.6k
Facilitating Awesome Meetings
lara
41
5.6k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
24
2.3k
The Cult of Friendly URLs
andyhume
74
5.7k
Done Done
chrislema
178
15k
How GitHub Uses GitHub to Build GitHub
holman
468
290k
Building a Scalable Design System with Sketch
lauravandoore
455
32k
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