mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2025-05-27 12:22:21 +00:00
docs: edit let
This commit is contained in:
parent
ea5f8d16d1
commit
581e760b20
@ -448,7 +448,7 @@ if (true)
|
||||
|
||||
上面代码中,块级作用域将两个语句封装在一起。但是,在块级作用域以外,没有办法得到`t`的值,因为块级作用域不返回值,除非`t`是全局变量。
|
||||
|
||||
现在有一个[提案](http://wiki.ecmascript.org/doku.php?id=strawman:do_expressions),使得块级作用域可以变为表达式,也就是说可以返回值,办法就是在块级作用域之前加上`do`,使它变为`do`表达式。
|
||||
现在有一个[提案](http://wiki.ecmascript.org/doku.php?id=strawman:do_expressions),使得块级作用域可以变为表达式,也就是说可以返回值,办法就是在块级作用域之前加上`do`,使它变为`do`表达式,然后就会返回内部最后执行的表达式的值。
|
||||
|
||||
```javascript
|
||||
let x = do {
|
||||
@ -457,7 +457,7 @@ let x = do {
|
||||
};
|
||||
```
|
||||
|
||||
上面代码中,变量`x`会得到整个块级作用域的返回值。
|
||||
上面代码中,变量`x`会得到整个块级作用域的返回值(`t * t + 1`)。
|
||||
|
||||
## const 命令
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user