Skip to content

Commit 0a33fca

Browse files
committed
[충돌해결 및 번역] Part1 6.11 화살표 함수 다시 살펴보기
1 parent 16959ef commit 0a33fca

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

  • 1-js/06-advanced-functions/12-arrow-functions

1-js/06-advanced-functions/12-arrow-functions/article.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,8 @@ let group = {
5151
showList() {
5252
*!*
5353
this.students.forEach(function(student) {
54-
<<<<<<< HEAD
55-
// TypeError: Cannot read property 'title' of undefined
56-
alert(this.title + ': ' + student)
57-
=======
5854
// Error: Cannot read property 'title' of undefined
59-
alert(this.title + ': ' + student);
60-
>>>>>>> upstream/master
55+
alert(this.title + ': ' + student)
6156
});
6257
*/!*
6358
}
@@ -72,14 +67,15 @@ group.showList();
7267

7368
```warn header="화살표 함수는 `new`와 함께 실행할 수 없습니다."
7469
`this`가 없기 때문에 화살표 함수는 생성자 함수로 사용할 수 없다는 제약이 있습니다. 화살표 함수는 `new`와 함께 호출할 수 없습니다.
75-
```
70+
71+
````
7672
7773
```smart header="화살표 함수 vs. bind"
7874
화살표 함수와 일반 함수를 `.bind(this)`를 사용해서 호출하는 것 사이에는 미묘한 차이가 있습니다.
7975
8076
- `.bind(this)`는 함수의 '한정된 버전(bound version)'을 만듭니다.
8177
- 화살표 함수는 어떤 것도 바인딩시키지 않습니다. 화살표 함수엔 단지 `this`가 없을 뿐입니다. 화살표 함수에서 `this`를 사용하면 일반 변수 서칭과 마찬가지로 `this`의 값을 외부 렉시컬 환경에서 찾습니다.
82-
```
78+
````
8379

8480
## 화살표 함수엔 'arguments'가 없습니다
8581

@@ -91,13 +87,13 @@ group.showList();
9187

9288
```js run
9389
function defer(f, ms) {
94-
return function() {
90+
return function () {
9591
setTimeout(() => f.apply(this, arguments), ms);
9692
};
9793
}
9894

9995
function sayHi(who) {
100-
alert('안녕, ' + who);
96+
alert("안녕, " + who);
10197
}
10298

10399
let sayHiDeferred = defer(sayHi, 2000);
@@ -108,9 +104,9 @@ sayHiDeferred("철수"); // 2초 후 "안녕, 철수"가 출력됩니다.
108104

109105
```js
110106
function defer(f, ms) {
111-
return function(...args) {
107+
return function (...args) {
112108
let ctx = this;
113-
setTimeout(function() {
109+
setTimeout(function () {
114110
return f.apply(ctx, args);
115111
}, ms);
116112
};

0 commit comments

Comments
 (0)