1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-28 21:32:20 +00:00

Update proxy.md

this问题中添加对handler.construct钩子函数中this的描述
This commit is contained in:
chua 2020-09-15 21:11:55 +08:00 committed by GitHub
parent 9f1f925fc1
commit 48e318b12b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1053,6 +1053,8 @@ proxy.foo // TypeError: Revoked
## this 问题
正常情况下Proxy代理的钩子函数中的`this`指向的是Proxy代理实例construct钩子函数除外该钩子函数中`this`指向的是handler)
虽然 Proxy 可以代理针对目标对象的访问,但它不是目标对象的透明代理,即不做任何拦截的情况下,也无法保证与目标对象的行为一致。主要原因就是在 Proxy 代理的情况下,目标对象内部的`this`关键字会指向 Proxy 代理。
```javascript