mirror of
https://github.com/ruanyf/es6tutorial.git
synced 2024-04-21 12:32:22 +00:00
docs(async): 拆分 generator 函数的异步操作与 async 函数
This commit is contained in:
+3
-2
@@ -1549,7 +1549,7 @@ sum(1, 100000)
|
||||
|
||||
## 函数参数的尾逗号
|
||||
|
||||
ECMAScript 2017将[允许](https://github.com/jeffmo/es-trailing-function-commas)函数的最后一个参数有尾逗号(trailing comma)。
|
||||
ES2017 [允许](https://github.com/jeffmo/es-trailing-function-commas)函数的最后一个参数有尾逗号(trailing comma)。
|
||||
|
||||
此前,函数定义和调用时,都不允许最后一个参数后面出现逗号。
|
||||
|
||||
@@ -1567,7 +1567,7 @@ clownsEverywhere(
|
||||
|
||||
上面代码中,如果在`param2`或`bar`后面加一个逗号,就会报错。
|
||||
|
||||
这样的话,如果以后修改代码,想为函数`clownsEverywhere`添加第三个参数,就势必要在第二个参数后面添加一个逗号。这对版本管理系统来说,就会显示,添加逗号的那一行也发生了变动。这看上去有点冗余,因此新的语法允许定义和调用时,尾部直接有一个逗号。
|
||||
这样的话,如果以后修改代码,想为函数`clownsEverywhere`添加第三个参数,就势必要在第二个参数后面添加一个逗号。这对版本管理系统来说,就会显示添加逗号的那一行也发生了变动。这看上去有点冗余,因此新的语法允许定义和调用时,尾部直接有一个逗号。这与数组和对象的尾逗号规则,保持一致了。
|
||||
|
||||
```javascript
|
||||
function clownsEverywhere(
|
||||
@@ -1580,3 +1580,4 @@ clownsEverywhere(
|
||||
'bar',
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user