> For the complete documentation index, see [llms.txt](https://april.gitbook.io/learning-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://april.gitbook.io/learning-js/chapter-7./7.2.md).

# 7.2 정적 스코프와 동적 스코프

* 자바스크립트의 스코프는 **정적**임 -> 소스 코드만 봐도 변수가 스코프에 있는지 판단할 수 있음
* 단, 소크모드만 봐도 즉시 스코프를 분명히 알 수 있다는 뜻은 아님

### 정적 스코프

* 어떤 변수가 함수 스코프 안에 있는지 함수를 정의할 때 알 수 있다는 뜻
* 호출할 때 알 수 있는 것 X
* 전역 스코프, 블록 스코프, 함수 스코프에 적용됨

```javascript
const x = 3;

function f() {
    console.log(x);
    console.log(y); // y가 존재하지 않음
}

{ // 새 스코프
    const y = 5;
    f(); // y는 f() 의 바디 안 스코프에 없음
}
```
