Skip to content

Commit 0af6108

Browse files
committed
docs: edit reflect & destructuring
1 parent 90df0a9 commit 0af6108

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

docs/destructuring.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let b = 2;
1414
let c = 3;
1515
```
1616

17-
ES6允许写成下面这样
17+
ES6 允许写成下面这样
1818

1919
```javascript
2020
let [a, b, c] = [1, 2, 3];
@@ -348,10 +348,11 @@ let x;
348348
// SyntaxError: syntax error
349349
```
350350

351-
上面代码的写法会报错,因为JavaScript引擎会将`{x}`理解成一个代码块,从而发生语法错误。只有不将大括号写在行首,避免JavaScript将其解释为代码块,才能解决这个问题。
351+
上面代码的写法会报错,因为 JavaScript 引擎会将`{x}`理解成一个代码块,从而发生语法错误。只有不将大括号写在行首,避免 JavaScript 将其解释为代码块,才能解决这个问题。
352352

353353
```javascript
354354
// 正确的写法
355+
let x;
355356
({x} = {x: 1});
356357
```
357358

docs/reflect.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -415,19 +415,19 @@ Reflect.isExtensible(1) // 报错
415415
var myObject = {};
416416

417417
// 旧写法
418-
Object.isExtensible(myObject) // true
418+
Object.preventExtensions(myObject) // Object {}
419419

420420
// 新写法
421421
Reflect.preventExtensions(myObject) // true
422422
```
423423

424-
如果参数不是对象,`Object.isExtensible`在 ES5 环境报错,在 ES6 环境返回这个参数,而`Reflect.preventExtensions`会报错。
424+
如果参数不是对象,`Object.preventExtensions`在 ES5 环境报错,在 ES6 环境返回传入的参数,而`Reflect.preventExtensions`会报错。
425425

426426
```javascript
427-
// ES5
427+
// ES5 环境
428428
Object.preventExtensions(1) // 报错
429429

430-
// ES6
430+
// ES6 环境
431431
Object.preventExtensions(1) // 1
432432

433433
// 新写法

0 commit comments

Comments
 (0)