I have a problem with the online document of the website of jquery about javascript scope.There are codes;
(function() {
var baz = 1;
var bim = function() {
console.log( baz );
};
bar = function() {
console.log( baz );
};
})();
And says:
console.log( baz ); // baz is not defined outside of the function
the thing that I don't understand is that even though baz
is defined, why console.log(baz)
is undefined. Because I think the scope is the same. Did I miss something?