File tree Expand file tree Collapse file tree 3 files changed +95
-96
lines changed
1-js/06-advanced-functions/11-currying-partials Expand file tree Collapse file tree 3 files changed +95
-96
lines changed Original file line number Diff line number Diff line change 11
22
3- 1 . Either use a wrapper function, an arrow to be concise :
3+ 1 . Либо для краткости используйте стрелочную функцию-обёртку :
44
55 ``` js
66 askPassword (() => user .login (true ), () => user .login (false ));
77 ```
88
9- Now it gets ` user` from outer variables and runs it the normal way .
9+ Теперь ` user` берётся из внешних переменных, и всё выполняется правильно .
1010
11- 2. Or create a partial function from `user.login` that uses `user` as the context and has the correct first argument :
11+ 2. Либо сделайте из ` user.login` функцию частичного применения, которая использует ` user` как контекст, и которой передан корректный первый аргумент :
1212
1313
1414 ` ` ` js
Original file line number Diff line number Diff line change @@ -2,13 +2,13 @@ importance: 5
22
33---
44
5- # Partial application for login
5+ # Частичное применение для логина
66
7- The task is a little more complex variant of < info:task/question-use-bind > .
7+ Эта задача -- немного более усложнённый вариант < info:task/question-use-bind > .
88
9- The ` user ` object was modified. Now instead of two functions ` loginOk/loginFail ` , it has a single function ` user.login(true/false) ` .
9+ Объект ` user ` был изменён. Теперь вместо двух функций ` loginOk/loginFail ` , у него одна функция: ` user.login(true/false) ` .
1010
11- What to pass ` askPassword ` in the code below, so that it calls ` user.login(true) ` as ` ok ` and ` user.login(false) ` as ` fail ` ?
11+ Что нужно передать функции ` askPassword ` в коде ниже, чтобы она вызывала ` user.login(true) ` как ` ok ` и ` user.login(false) ` как ` fail ` ?
1212
1313``` js
1414function askPassword (ok , fail ) {
@@ -30,5 +30,5 @@ askPassword(?, ?); // ?
3030*/ ! *
3131` ` `
3232
33- Your changes should only modify the highlighted fragment .
33+ Вы можете изменять только подсвеченные фрагменты кода .
3434
You can’t perform that action at this time.
0 commit comments