Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f9c2e6

Browse files
committed
Update README.md
1 parent ac0377c commit 7f9c2e6

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

β€ŽREADME.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
[Let Declaration](#let-declaration)
4343

44-
Const Declaration
44+
[Const Declaration](#const-declaration)
4545

4646
[Spread Syntax](#spread-syntax)
4747

@@ -119,6 +119,54 @@ console.log(b) // -> ReferenceError: b is not defined πŸ‘
119119

120120
---
121121

122+
# Const Declaration
123+
124+
### μ •μ˜
125+
126+
블둝 레벨 유효 λ²”μœ„λ₯Ό κ°–λŠ” **μƒμˆ˜**λ₯Ό μ„ μ–Έν•©λ‹ˆλ‹€.
127+
128+
### νŠΉμ§•
129+
130+
`const` λŠ” μ„ μ–Έκ³Ό λ™μ‹œμ— ν• λ‹Ήν•΄μ•Ό ν•©λ‹ˆλ‹€. 즉 μ–Έμ œλ‚˜ μ΄ˆκΉƒκ°’μ„ ν•„μš”λ‘œ ν•©λ‹ˆλ‹€.
131+
132+
`const` λŠ” μž¬ν• λ‹Ή ν•  수 μ—†μŠ΅λ‹ˆλ‹€.
133+
134+
`const` λŠ” `let` κ³Ό λ™μΌν•˜κ²Œ 블둝 레벨 유효 λ²”μœ„λ₯Ό κ°€μ§‘λ‹ˆλ‹€.
135+
136+
### 1. μ„ μ–Έκ³Ό λ™μ‹œμ— ν• λ‹Ή
137+
138+
πŸ‘‰μ‹œλ‚˜λ¦¬μ˜€: `const` κ°€ μ„ μ–Έκ³Ό λ™μ‹œμ— ν• λ‹Ήν•΄μ•Ό 함을 증λͺ…ν•˜μ„Έμš”.
139+
140+
```js
141+
const a = 1
142+
const b // -> SyntaxError: Missing initializer in const declaration
143+
```
144+
145+
### 2. μž¬ν• λ‹Ή λΆˆκ°€λŠ₯
146+
147+
πŸ‘‰μ‹œλ‚˜λ¦¬μ˜€: `const` κ°€ μž¬ν• λ‹Ή λΆˆκ°€λŠ₯함을 증λͺ…ν•˜μ„Έμš”.
148+
149+
```js
150+
const a = 1
151+
a = 2 // -> TypeError: Assignment to constant variable
152+
```
153+
154+
### 3. 유효 λ²”μœ„
155+
156+
πŸ‘‰μ‹œλ‚˜λ¦¬μ˜€: `const` κ°€ `let` κ³Ό λ™μΌν•˜κ²Œ 블둝 레벨 유효 λ²”μœ„λ₯Ό κ°€μ§€λŠ” 것을 증λͺ…ν•˜μ„Έμš”.
157+
158+
```js
159+
if (true) {
160+
var a = 1
161+
const b = 1
162+
}
163+
164+
console.log(a) // -> 1
165+
console.log(b) // -> ReferenceError: b is not defined πŸ‘
166+
```
167+
168+
---
169+
122170
# Spread Syntax
123171

124172
### μ •μ˜

0 commit comments

Comments
Β (0)