Skip to content

Instantly share code, notes, and snippets.

@leolanese
Last active April 10, 2020 04:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leolanese/95d157dfd7f1edce71c997b12437f1e9 to your computer and use it in GitHub Desktop.
Save leolanese/95d157dfd7f1edce71c997b12437f1e9 to your computer and use it in GitHub Desktop.
Functional Programming: Object Composition
// 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