hoisting : JS 엔진(interpreter)이 코드를 실행하기 전, 변수, 함수, 클래스의 선언문을 끌어 올리는 것을 말함
변수 variable : 값을 저장하는 공간, 자료를 저장할 수 있는 이름이 주어진 기억장소
함수의 호이스팅은 함수의 선언문 전에 호출이 가능하게 해줌
print(); // Hello
function print(){
console.log('Hello')
}
console.log(hi); // Cannot access 'hi' before initialization
let hi ='hi';
let func1 = function() {};
const cat = new Cat(); // Cannot access 'Cat' before initialization
class Cat{}
// 블러 안에서 변수 선언도 동일하게 작용
let x = 1;
{
console.log(x);
let x = 2; // Cannot access 'x' before initialization
}