1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

docs(Symbol): edit Symbol.unscopables

This commit is contained in:
Ruan YiFeng 2017-01-25 09:24:20 +08:00 committed by GitHub
parent 4b17bc8a16
commit dcb12a1be9

View File

@ -807,15 +807,16 @@ Array.prototype[Symbol.unscopables]
// entries: true,
// fill: true,
// find: true,
// findIndex: true,
//   findIndex: true,
// includes: true,
// keys: true
// }
Object.keys(Array.prototype[Symbol.unscopables])
// ['copyWithin', 'entries', 'fill', 'find', 'findIndex', 'keys']
// ['copyWithin', 'entries', 'fill', 'find', 'findIndex', 'includes', 'keys']
```
上面代码说明,数组有6个属性会被with命令排除。
上面代码说明,数组有7个属性会被`with`命令排除。
```javascript
// 没有 unscopables 时
@ -844,3 +845,4 @@ with (MyClass.prototype) {
}
```
上面代码通过指定`Symbol.unscopables`属性,使得`with`语法块不会在当前作用域寻找`foo`属性,即`foo`将指向外层作用域的变量。