Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- underscores
- 엔퀸즈
- JS
- 초보
- 제일어려워
- JavaScript
- array
- 포스기
- ftech
- vscode
- 코드스테이츠
- 일상
- 해커톤
- 공부
- 클라이언트
- 취업
- 알고리즘
- 자바스크립트
- 연습
- grpahQL
- Instantiation Patterns
- method
- this
- underbar
- 리액트
- DOM
- react
- nqueens
- 개발
- 코딩
Archives
- Today
- Total
analogcoding
arrow function 의 this context 본문
일반적인 함수의 경우 this 가 참조하는 값을 binding 해줘야한다.

arrow function 을 사용하지 않을 때 this === window 가 true 이다.

this.pruntData() 는 이미 myObj 를 바라보고 있어서 window가 아니기 때문에 bind로 this를 묶어줘야 한다.
그렇지만 arrow function을 사용할 경우

binding을 따로 해주지 않아도 바로 연결된다.

그렇지만 this 가 window 를 바라보는 것은 아니다.
bind 를 생략한 상태에서도 context 를 유지하기 때문에 'where is this' 가 출력된다.
'Study JS for me > Keyword' 카테고리의 다른 글
| function default parameters (0) | 2019.05.14 |
|---|---|
| Destructuring (0) | 2019.05.14 |
| arrow function 예시 (0) | 2019.05.14 |
| Object property (0) | 2019.05.13 |
| spread operator / rest parameter (0) | 2019.05.13 |
Comments