Fix typos in 'Proxy and Reflect'
This commit is contained in:
parent
dccca58f26
commit
b83f2d7f1d
3 changed files with 6 additions and 6 deletions
|
@ -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"
|
||||
```
|
||||
|
|
|
@ -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"
|
||||
*/!*
|
||||
```
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue