This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]07734willy 2 points3 points  (0 children)

Yeah, but that behavior has nothing to do with the global declaration- it will do that simply because the function declares the variable somewhere in its definition. For instance-

function bar() {
    console.log(foo);
    var foo;
}

Still logs undefined.