mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-24 18:32:22 +00:00
Update destructuring.md
我的陋解:析构赋值等号右边如果是数组的话,就不用转换成对象。按照数组的规则赋值就可以了。请指正。
This commit is contained in:
parent
c108637656
commit
d6cf4631eb
@ -420,7 +420,7 @@ s === Boolean.prototype.toString // true
|
||||
|
||||
上面代码中,数值和布尔值的包装对象都有`toString`属性,因此变量`s`都能取到值。
|
||||
|
||||
解构赋值的规则是,只要等号右边的值不是对象,就先将其转为对象。由于`undefined`和`null`无法转为对象,所以对它们进行解构赋值,都会报错。
|
||||
解构赋值的规则是,只要等号右边的值不是对象或数组,就先将其转为对象。由于`undefined`和`null`无法转为对象,所以对它们进行解构赋值,都会报错。
|
||||
|
||||
```javascript
|
||||
let { prop: x } = undefined; // TypeError
|
||||
|
Loading…
x
Reference in New Issue
Block a user