Skip to content

Commit e0ecb0f

Browse files
codeudanruanyf
authored andcommitted
docs(function): 调整不合适的函数描述
1 parent 936940b commit e0ecb0f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

docs/function.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ const square = n => n * n;
669669
箭头函数的一个用处是简化回调函数。
670670

671671
```javascript
672-
// 正常函数写法
672+
// 普通函数写法
673673
[1,2,3].map(function (x) {
674674
return x * x;
675675
});
@@ -681,7 +681,7 @@ const square = n => n * n;
681681
另一个例子是
682682

683683
```javascript
684-
// 正常函数写法
684+
// 普通函数写法
685685
var result = values.sort(function (a, b) {
686686
return a - b;
687687
});
@@ -716,7 +716,7 @@ headAndTail(1, 2, 3, 4, 5)
716716

717717
(4)不可以使用`yield`命令,因此箭头函数不能用作 Generator 函数。
718718

719-
上面四点中,最重要的是第一点。对于普通函数来说,内部的`this`代表函数运行时所在的对象,但是这一点对箭头函数不成立。它没有自己的`this`对象,内部的`this`就是一个普通变量,指向定义时上层函数所在的对象。也就是说,箭头函数内部的`this`指向是固定的,相比之下,普通函数的`this`指向是可变的。
719+
上面四点中,最重要的是第一点。对于普通函数来说,内部的`this`指向函数运行时所在的对象,但是这一点对箭头函数不成立。它没有自己的`this`对象,内部的`this`就是定义时上层作用域中的`this`。也就是说,箭头函数内部的`this`指向是固定的,相比之下,普通函数的`this`指向是可变的。
720720

721721
```javascript
722722
function foo() {

0 commit comments

Comments
 (0)