"this" context output not able to understand
<p>I am facing difficulty understanding the below code.</p>

<pre><code>function foo() {
    console.log( this.a );
}

var obj = {
    a: 2,
    foo: foo
};

var a = 4;

obj.foo();
setTimeout( obj.foo, 100 );
setTimeout( obj.foo.bind(obj), 100 );
</code></pre>

<p>Its output comes as 2, 4, 2 which I am not able to understand.</p>