1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-25 11:12:21 +00:00

docs(proxy): fix constrct()

This commit is contained in:
ruanyf 2020-09-15 11:11:57 +08:00
parent 50b25c1a64
commit f81d202a09

View File

@ -601,7 +601,7 @@ for (let b in oproxy2) {
### construct() ### construct()
`construct`方法用于拦截`new`命令,下面是拦截对象的写法。 `construct()`方法用于拦截`new`命令,下面是拦截对象的写法。
```javascript ```javascript
var handler = { var handler = {
@ -611,11 +611,11 @@ var handler = {
}; };
``` ```
`construct`方法可以接受三个参数。 `construct()`方法可以接受三个参数。
- `target`:目标对象 - `target`:目标对象
- `args`:构造函数的参数对象 - `args`:构造函数的参数数组。
- `newTarget`:创造实例对象时,`new`命令作用的构造函数(下面例子的`p` - `newTarget`:创造实例对象时,`new`命令作用的构造函数(下面例子的`p`
```javascript ```javascript
var p = new Proxy(function () {}, { var p = new Proxy(function () {}, {
@ -630,7 +630,7 @@ var p = new Proxy(function () {}, {
// 10 // 10
``` ```
`construct`方法返回的必须是一个对象,否则会报错。 `construct()`方法返回的必须是一个对象,否则会报错。
```javascript ```javascript
var p = new Proxy(function() {}, { var p = new Proxy(function() {}, {