This commit is contained in:
Ilya Kantor 2019-05-22 02:37:20 +03:00
parent db32cd032c
commit 7f1d5de09e
2 changed files with 3 additions and 5 deletions

View file

@ -38,6 +38,6 @@ An alternative solution could be:
askPassword(() => user.loginOk(), () => user.loginFail());
```
Usually that also works, but may fail in more complex situations where `user` has a chance of being overwritten between the moments of asking and running `() => user.loginOk()`.
Usually that also works and looks good.
It's a bit less reliable though in more complex situations where `user` variable might change *after* `askPassword` is called, but *before* the visitor answers and calls `() => user.loginOk()`.

View file

@ -2,7 +2,7 @@ importance: 5
---
# Ask losing this
# Fix a function that loses "this"
The call to `askPassword()` in the code below should check the password and then call `user.loginOk/loginFail` depending on the answer.
@ -34,5 +34,3 @@ let user = {
askPassword(user.loginOk, user.loginFail);
*/!*
```