Skip to content

Commit 768728e

Browse files
committed
docs(function): edit function
1 parent c2d5bb2 commit 768728e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/function.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### 基本用法
66

7-
在ES6之前,不能直接为函数的参数指定默认值,只能采用变通的方法。
7+
ES6 之前,不能直接为函数的参数指定默认值,只能采用变通的方法。
88

99
```javascript
1010
function log(x, y) {
@@ -73,7 +73,7 @@ function foo(x, x, y = 1) {
7373
// SyntaxError: Duplicate parameter name not allowed in this context
7474
```
7575

76-
另外,一个容易忽略的地方是,如果参数默认值是变量,那么参数就不是传值的,而是每次都重新计算默认值表达式的值。也就是说,参数默认值是惰性求值的。
76+
另外,一个容易忽略的地方是,参数默认值不是传值的,而是每次都重新计算默认值表达式的值。也就是说,参数默认值是惰性求值的。
7777

7878
```javascript
7979
let x = 99;
@@ -301,7 +301,7 @@ let foo = 'outer';
301301

302302
function bar(func = x => foo) {
303303
let foo = 'inner';
304-
console.log(func());
304+
console.log(func());
305305
}
306306

307307
bar(); // outer
@@ -379,9 +379,9 @@ foo()
379379
function foo(optional = undefined) { ··· }
380380
```
381381

382-
## rest参数
382+
## rest 参数
383383

384-
ES6 引入 rest 参数(形式为...变量名),用于获取函数的多余参数,这样就不需要使用`arguments`对象了。rest 参数搭配的变量是一个数组,该变量将多余的参数放入数组中。
384+
ES6 引入 rest 参数(形式为`...变量名`),用于获取函数的多余参数,这样就不需要使用`arguments`对象了。rest 参数搭配的变量是一个数组,该变量将多余的参数放入数组中。
385385

386386
```javascript
387387
function add(...values) {
@@ -853,7 +853,7 @@ foo.bind({}).name // "bound foo"
853853

854854
### 基本用法
855855

856-
ES6允许使用“箭头”(`=>`)定义函数。
856+
ES6 允许使用“箭头”(`=>`)定义函数。
857857

858858
```javascript
859859
var f = v => v;

0 commit comments

Comments
 (0)