Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[오타수정] 파트 1 6.4 오래된 'var' - 2차 리뷰 #1167#1198

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
KwanHoo wants to merge1 commit intojavascript-tutorial:master
base:master
Choose a base branch
Loading
fromKwanHoo:upstream/issue-#1167
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions1-js/06-advanced-functions/04-var/article.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -85,22 +85,22 @@ alert(phrase); // Error: phrase is not defined

위에서 살펴본 바와 같이, `var`는 `if`, `for` 등의 코드 블록을 관통합니다. 아주 오래전의 자바스크립트에선 블록 수준 렉시컬 환경이 만들어 지지 않았기 때문입니다. `var`는 구식 자바스크립트의 잔재이죠.

## "var" tolerates redeclarations
## "var"는 재선언을 용인합니다.

If we declare the same variable with`let` twice in the same scope, that's an error:
같은 변수를 동일한 스코프에서`let`과 두 번 선언한다면 에러입니다.

```js run
let user;
let user; // SyntaxError: 'user' has already been declared
```

With`var`, we can redeclare a variable any number of times. If we use `var` with an already-declared variable, it's just ignored:
`var`를 사용하면 같은 변수를 여러 번 재선언 할 수 있습니다. 이미 선언된 변수에 `var`를 사용하면 무시됩니다.

```js run
var user = "Pete";

var user = "John"; //this "var" does nothing (already declared)
//...it doesn't trigger an error
var user = "John"; // "var"는 아무것도 하지 않습니다 (이미 선언됨).
//에러가 발생하지 않습니다.

alert(user); // John
```
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp