I am learning javascript and my current understanding is the main way javascript uses for scoping is the function scope, and there are no block scopes in general.
So I came up with this:
var obj = {
foo: function myfunc() {
console.log("123");
}
};
myfunc();
I thought because javascript doesn't have block scoping, the definition of myfunc()
will be visible in global scope. But it actually did not. Can someone help to explain this?