-
Notifications
You must be signed in to change notification settings - Fork 16
[2주차] 스코프 #155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ddongule
wants to merge
4
commits into
fe-backpackers:ddongule
Choose a base branch
from
ddongule:scope
base: ddongule
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[2주차] 스코프 #155
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # 스코프 | ||
|
|
||
| | 변수의 유효 범위 | ||
|
|
||
| - 변수나 함수의 접근 가능 여부를 결정하기 위한 공간 규칙 | ||
|
|
||
| - 스코프는 크게 함수 스코프와 변수 스코프로 나뉠 수 있음 | ||
|
|
||
| - 함수 스코프: 함수 단위로 발생하는 스코프 | ||
| - 블록 스코프: 블록(`{}`) 단위로 발생하는 스코프 | ||
|
|
||
| ### 심화 학습 | ||
|
|
||
| - 호이스팅 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # 실행 컨텍스트 | ||
|
|
||
| | 코드가 실행하기 위해 필요한 주변 환경 정보들을 모아둔 객체 | ||
|
|
||
| - 자바스크립트에서는 코드가 실행하기 위해 필요한 주변 환경 정보들을 모아두는데, 이를 실행 컨텍스트라고 한다. | ||
| - 블록에 의해서 구성된다. | ||
|
|
||
| ### Variable Environment(변수 환경)와 Lexical Environment(렉시컬 환경)으로 나눌 수 있다 | ||
|
|
||
| #### Variable Environment | ||
|
|
||
| - 딱 실행되면 처음에 딱 외부 환경을 수집해 저장해놓는다. (변경되지 않음) | ||
| - 현재의 컨텍스트와 관련된 코드의 변수를 수집한다. (호이스팅) | ||
|
|
||
| #### Lexical Environment | ||
|
|
||
| - 처음에는 Variable Environment와 같다. | ||
| - 실시간으로 변경사항을 반영한다. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # 이벤트 루프 | ||
|
|
||
| | Task Queue에서 하나씩 이벤트들을 꺼내 콜스택으로 올려 동작시키는 루프를 말한다. | ||
|
|
||
| - 자바스크립트는 싱글 스레드 기반 언어이기 때문에 한 번에 하나씩 작업을 진행 | ||
| - 이벤트 루프에서는 이벤트 발생 시 호출되는 콜백 함수들을 태스크 큐에 전달하고, 태스크 큐에 담긴 콜백 함수들을 콜스택에 넘겨주는 역할을 함 | ||
|
|
||
| #### 비동기 작업 실행 순서 | ||
|
|
||
| 1. 코드가 호출 스택에 쌓임 | ||
| 2. 자바스크립트 엔진은 비동기 작업을 Web API에게 넘김 | ||
| 3. Web API는 비동기 작업을 수행하고, 콜백 함수를 이벤트 루프를 통해 태스크 큐에 넘겨줌 | ||
| 4. 이벤트 루프는 콜스택과 태스크 큐를 보고 있다가, 콜스택에 쌓인 게 없으면 콜백함수를 콜스택으로 넘겨줌 | ||
| 5. 콜스택에 쌓인 콜백함수가 실행, 콜스택에서 제거됨 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # 이벤트 위임 | ||
|
|
||
| | 상위 노드에서 하위 노드의 이벤트를 제어하는 방식 | ||
|
|
||
| #### 이벤트 버블링 | ||
|
|
||
| - 특정 요소에 이벤트가 발생했을 때, 해당 이벤트가 그 요소의 상위 요소로 전달되는 것 | ||
|
|
||
| #### 이벤트 캡쳐링 | ||
|
|
||
| - window로부터 이벤트가 발생되는 곳을 찾으려 하는 것 | ||
|
|
||
| #### 이벤트 동작 방식 | ||
|
|
||
| 1. 이벤트가 발생되는 곳을 확인하기 위해 캡쳐링을 해서 감지함 | ||
| 2. Target을 발견함 | ||
| 3. Bubbling을 수행함 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기에서 "함수 스코프", "변수 스코프" 로 구분하셨는데 바로 밑에서 "변수 스코프" 대신 "블록 스코프"라는 용어가 나와서 조금 헷갈리는거 같습니다