Javascript initial a null varible for us at the top of the function whether it's assigned or not.
Example:
function bakery( ) {
if(false) {
var cake = "butter" ;
}
}
What it will actually do is:
function bakery() {
var cake;
if(false) {
var cake = "butter" ;
}
}
That's what we call hoisting.
沒有留言:
張貼留言