Last active
April 10, 2020 04:38
-
-
Save leolanese/95d157dfd7f1edce71c997b12437f1e9 to your computer and use it in GitHub Desktop.
Functional Programming: Object Composition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
```javascript | |
function sum(a) { | |
return function(b) { | |
return function(c) { | |
return a + b + c; | |
}; | |
}; | |
} | |
``` | |
// 2 | |
```javascript | |
function sum(a) { | |
return b => c => a + b + c; | |
} | |
sum(3)(4)(5); | |
``` | |
// 3 | |
```javascript | |
// in this case we stuck on 3 parameters | |
let add = (a, b, c) => a + b + c; | |
console.log(add(3, 4, 5)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment