끌어올리다
var
: 호이스팅 (선언부만)let
, const
: 호이스팅 Xvar
로 표현됐을 경우 선언부만 호이스팅 됨)count(); var count = function() { console.log('count는 1이다.'); }
TypeError: count is not a function
- 선언부(
var count
)만 호이스팅 됨. 변수 count는undefined
상태.- 이 상태에서 호출되었으므로
count is not a function
이라는 타입 에러가 뜬다.
var count = function() { console.log('count는 1이다.'); } count();
'count는 1이다'
- 함수가 정상적으로 호출됨
count(); let count = function() { console.log('count는 1이다.'); }
ReferenceError: count is not defined
let
은 호이스팅 되지 않으므로count is not defined
라는ReferenceError
가 발생한다.