From 083c99e838b487d18642042bf9c33ead93c57a18 Mon Sep 17 00:00:00 2001 From: zhangbao Date: Mon, 1 Jan 2018 18:23:16 +0800 Subject: [PATCH] =?UTF-8?q?docs(destructuring):=20=E8=A1=A5=E5=85=A8?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 这样直接看代码的话,更能直观了解到要先声明 y 才能使用它,而不是在声明 y 前就使用它。 --- docs/destructuring.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/destructuring.md b/docs/destructuring.md index 3d1cc73..82acefb 100644 --- a/docs/destructuring.md +++ b/docs/destructuring.md @@ -169,10 +169,10 @@ if ([1][0] === undefined) { let [x = 1, y = x] = []; // x=1; y=1 let [x = 1, y = x] = [2]; // x=2; y=2 let [x = 1, y = x] = [1, 2]; // x=1; y=2 -let [x = y, y = 1] = []; // ReferenceError +let [x = y, y = 1] = []; // ReferenceError: y is not defined ``` -上面最后一个表达式之所以会报错,是因为`x`用到默认值`y`时,`y`还没有声明。 +上面最后一个表达式之所以会报错,是因为`x`用`y`做默认值时,`y`还没有声明。 ## 对象的解构赋值