From d6cf4631ebcbf64814340b291692421cba83cb58 Mon Sep 17 00:00:00 2001 From: KurryLuo Date: Sun, 26 Feb 2017 10:53:59 +0800 Subject: [PATCH] Update destructuring.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 我的陋解:析构赋值等号右边如果是数组的话,就不用转换成对象。按照数组的规则赋值就可以了。请指正。 --- docs/destructuring.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/destructuring.md b/docs/destructuring.md index bf35f9e..4f5d3c9 100644 --- a/docs/destructuring.md +++ b/docs/destructuring.md @@ -420,7 +420,7 @@ s === Boolean.prototype.toString // true 上面代码中,数值和布尔值的包装对象都有`toString`属性,因此变量`s`都能取到值。 -解构赋值的规则是,只要等号右边的值不是对象,就先将其转为对象。由于`undefined`和`null`无法转为对象,所以对它们进行解构赋值,都会报错。 +解构赋值的规则是,只要等号右边的值不是对象或数组,就先将其转为对象。由于`undefined`和`null`无法转为对象,所以对它们进行解构赋值,都会报错。 ```javascript let { prop: x } = undefined; // TypeError