Skip to content

Commit 2ffc72e

Browse files
committed
📝 Add TOC
1 parent 56d1948 commit 2ffc72e

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

this.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,26 @@
22

33
> Javascript에서 this는 무엇인가?
44
5+
[Table of Contents]
6+
7+
- [상황에 따른 this](#상황에-따른-this)
8+
- [global scope](#global-scope)
9+
- [Object's method](#objects-method)
10+
- [call, apply, bind](#call-apply-bind)
11+
- [arrow function](#arrow-function)
12+
- [new](#new)
13+
- [callback (서브루틴)](#callback-서브루틴)
14+
- [실전 문제들](#실전-문제들)
15+
- [Variable vs property](#variable-vs-property)
16+
- [Cat name](#cat-name)
17+
- [Delayed greeting](#delayed-greeting)
18+
- [Artificial method](#artificial-method)
19+
- [Greeting and farewell](#greeting-and-farewell)
20+
- [Tricky length](#tricky-length)
21+
- [Calling arguments](#calling-arguments)
22+
23+
---
24+
525
this가 무엇인지 대답하라고 할 때 보통 상황마다 다른 this를 대답하곤 한다.
626

727
"그래서 this가 뭔데요?"
@@ -10,9 +30,7 @@ this가 무엇인지 대답하라고 할 때 보통 상황마다 다른 this를
1030

1131
실행문맥이란 말은 호출자가 누구인지와 같다.
1232

13-
콘텍스트(context) 객체는 this가 바라보고 있는 어떤 객체이다.
14-
15-
그렇다면 역으로 this는 context를 가리키는 객체이다.
33+
콘텍스트(context) 객체는 this가 바라보고 있는 어떤 객체이며 반대로 표현하면 this는 context를 가리키는 것이다.
1634

1735
this가 변하는 상황을 먼저 나열해보자
1836

@@ -27,7 +45,9 @@ this가 변하는 상황을 먼저 나열해보자
2745

2846
---
2947

30-
## global scope
48+
## 상황에 따른 this
49+
50+
### global scope
3151

3252
전역공간에서의 this는 전역객체를 가리킨다.
3353

@@ -42,7 +62,7 @@ var a = 1;
4262
this.a; // 1
4363
```
4464

45-
## Object's method
65+
### Object's method
4666

4767
함수는 자체로 독립적인 기능을 수행
4868

@@ -86,7 +106,7 @@ testObj.outerFunc();
86106

87107
outerFunc 내부의 innerFunc에서 this는 전역 객체가 된다. 이는 callback에서 더 자세히 다룬다.
88108

89-
## call, apply, bind
109+
### call, apply, bind
90110

91111
함수에 명시적으로 this를 바인딩 할 수 있다.
92112

@@ -107,7 +127,7 @@ bind의 경우는 this 바인딩만 해주고 실행은 직접 해줘야 한다.
107127
func.bind(this, `param1`, `param2`);
108128
```
109129

110-
## arrow function
130+
### arrow function
111131

112132
화살표 함수는 함수를 선언할 때 this에 바인딩할 객체가 정적으로 결정되며, 화살표 함수를 둘러싸는 렉시컬 스코프(lexical scope)의 this가 사용된다.
113133

@@ -146,7 +166,7 @@ arrowObj.func(); // outer function
146166
funcObj.func(); // object function
147167
```
148168

149-
## new
169+
### new
150170

151171
생성자 함수에서는 인스턴스 자신이된다. (class와 비슷함)
152172

@@ -159,7 +179,7 @@ var Obj = function (name, age) {
159179
var obj = new Obj("나비", 1); // {name:"나비", age:1}
160180
```
161181

162-
## callback (서브루틴)
182+
### callback (서브루틴)
163183

164184
콜백함수의 제어권을 가지는 함수(메서드)마다 다르다
165185

0 commit comments

Comments
 (0)