After I have examples of closures (function accounts) in Scala and JavaFX had imagined, let's look the same example in JavaScript (ECMAScript ) to:
/ / closures.js
zaehlerMitStartwert function (start value) {
return function () {return
starting value + +
}}
next1 = zaehlerMitStartwert (10)
next2 = zaehlerMitStartwert (20)
document.writeln (next1 ( ) document.writeln) / / 10
(next2 document.writeln ()) / / 20
(next2 document.writeln ()) / / 21
(next1 ()) / / 11
Much more can be found to really to say except that it
- really is that simple (which can also lead to problems )
- since the first versions of JavaScript (and thus For over 10 years) is available and
- unlike JavaFX Script is dynamically typed, and Scala, also no additional local variable is needed because of the transfer parameters
0 comments:
Post a Comment