티스토리 뷰

learning

함수 생성

눈침침 2011. 3. 25. 08:18
foo; // 'undefined'
foo(); // this raises a TypeError
var foo = function() {};
Due to the fact that var is a declaration, that hoists(=올리다.) the variable name foo before the actual execution of the code starts, foo is already defined when the script gets executed.
JavaScript Garden

즉 다음과 같은 코드로 해석된다는 이야기.

var foo;
foo; // 'undefined'
foo(); // this raises a TypeError
foo = function() {};
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함