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

Merge pull request #339 from kurryluo/patch-1

Update destructuring.md
This commit is contained in:
Ruan YiFeng 2017-02-26 12:07:06 +08:00 committed by GitHub
commit 2116dce29d

View File

@ -420,7 +420,7 @@ s === Boolean.prototype.toString // true
上面代码中,数值和布尔值的包装对象都有`toString`属性,因此变量`s`都能取到值。
解构赋值的规则是,只要等号右边的值不是对象,就先将其转为对象。由于`undefined``null`无法转为对象,所以对它们进行解构赋值,都会报错。
解构赋值的规则是,只要等号右边的值不是对象或数组,就先将其转为对象。由于`undefined``null`无法转为对象,所以对它们进行解构赋值,都会报错。
```javascript
let { prop: x } = undefined; // TypeError