up
This commit is contained in:
parent
4ae129054e
commit
ab9ab64bd5
476 changed files with 3370 additions and 532 deletions
|
@ -0,0 +1,17 @@
|
|||
For the second brackets to work, the first ones must return a function.
|
||||
|
||||
Like this:
|
||||
|
||||
```js run
|
||||
function sum(a) {
|
||||
|
||||
return function(b) {
|
||||
return a + b; // takes "a" from the outer lexical environment
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
alert( sum(1)(2) ); // 3
|
||||
alert( sum(5)(-1) ); // 4
|
||||
```
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue