currying
This commit is contained in:
parent
799d373a9b
commit
25a77d376a
7 changed files with 308 additions and 307 deletions
16
1-js/06-advanced-functions/10-bind/6-ask-partial/solution.md
Normal file
16
1-js/06-advanced-functions/10-bind/6-ask-partial/solution.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
|
||||
1. Either use a wrapper function, an arrow to be concise:
|
||||
|
||||
```js
|
||||
askPassword(() => user.login(true), () => user.login(false));
|
||||
```
|
||||
|
||||
Now it gets `user` from outer variables and runs it the normal way.
|
||||
|
||||
2. Or create a partial function from `user.login` that uses `user` as the context and has the correct first argument:
|
||||
|
||||
|
||||
```js
|
||||
askPassword(user.login.bind(user, true), user.login.bind(user, false));
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue