File tree 1 file changed +49
-1
lines changed
1 file changed +49
-1
lines changed Original file line number Diff line number Diff line change 41
41
42
42
[ Let Declaration] ( #let-declaration )
43
43
44
- Const Declaration
44
+ [ Const Declaration] ( #const-declaration )
45
45
46
46
[ Spread Syntax] ( #spread-syntax )
47
47
@@ -119,6 +119,54 @@ console.log(b) // -> ReferenceError: b is not defined π
119
119
120
120
---
121
121
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
+
122
170
# Spread Syntax
123
171
124
172
### μ μ
You canβt perform that action at this time.
0 commit comments