Fix typos in 'Proxy and Reflect'

This commit is contained in:
Vse Mozhe Buty 2020-11-04 20:32:44 +02:00
parent dccca58f26
commit b83f2d7f1d
3 changed files with 6 additions and 6 deletions

View file

@ -19,5 +19,5 @@ function wrap(target) {
user = wrap(user);
alert(user.name); // John
alert(user.age); // ReferenceError: Property doesn't exist "age"
alert(user.age); // ReferenceError: Property doesn't exist: "age"
```

View file

@ -27,6 +27,6 @@ user = wrap(user);
alert(user.name); // John
*!*
alert(user.age); // ReferenceError: Property doesn't exist "age"
alert(user.age); // ReferenceError: Property doesn't exist: "age"
*/!*
```

View file

@ -437,7 +437,7 @@ user = {
```
A call to `user.checkPassword()` call gets proxied `user` as `this` (the object before dot becomes `this`), so when it tries to access `this._password`, the `get` trap activates (it triggers on any property read) and throws an error.
A call to `user.checkPassword()` gets proxied `user` as `this` (the object before dot becomes `this`), so when it tries to access `this._password`, the `get` trap activates (it triggers on any property read) and throws an error.
So we bind the context of object methods to the original object, `target`, in the line `(*)`. Then their future calls will use `target` as `this`, without any traps.