Scope of self-invocation function in Javascript
<p>Why does self-invocation function inside a function don't get the scope of the outer function in JavaScript? </p>

<pre><code>var prop = "global";

var hash = {
    prop: "hash prop",
    foo: function(){
        console.log(this.prop);
        (function bar(){
            console.log(this.prop);
        })();
    }
};

var literal = {
    prop: "object"
};

hash.foo();
// hash prop
// global

hash.foo.call(literal);
// object
// global
</code></pre>

<p>Looks like altering the scope of the outer function has no effect on the scope of the inner self-invocation function.</p>

<p>PS: The question is not about how to alter the scope of the inner function. But what is the proper explanation in the "Javascript language" perspective? Does all self executing functions have 'global' scope by default? If so, why? </p>
