TDZ (Temporal Dead Zone)
๋จผ์ ์๋ ์ฝ๋๋ฅผ ์ดํด๋ณด์.
new Car('red'); // Does it work? (no; ReferenceError)
class Car {
constructor(color) {
this.color = color;
}
}
๋๋ ๋น์ฐํ ํด๋์ค๋ ํธ์ด์คํ ๋์ด ์ฌ์ฉ์ด ๊ฐ๋ฅํ ์ค ์์์ผ๋, ์๋์๋ค. ์ฐธ๊ณ ๋ก ํจ์๋ ๊ฐ๋ฅํ๋ค.
greet('World'); // Does it work? (yes)
function greet(who) {
return `Hello, ${who}!`;
}
์๊ฐํด๋ณด๋ฉด ES6๋ถํฐ๋ ํญ์ strict ๋ชจ๋๋ก ํด์๋๊ธฐ ๋๋ฌธ์ ์์ ๊ฐ๋ฅํ ๊ฒฐ๊ณผ์๋ค.
let
, const
, class
ํค์๋๋ TDZ์ ์ํฅ์ ๋ฐ์ผ๋ฏ๋ก ์ฃผ์ํด์ผ๊ฒ ๋ค.
Links
Last updated
Was this helpful?