JS Query- Global Window Object
<p><a href="http://jsfiddle.net/yjcXe/" rel="nofollow">This code generates x is not defined</a></p>

<pre><code>var myobj1 = 
{  
    x:9, 
    myfunction:function()
    {
        if(this === window) 
            alert("x is not Defined");
        else if (this === myobj1)
            alert(this.x);
        else
            alert("Error!");
    }
}

function test()
{
    setTimeout(myobj1.myfunction, 1000);
}

test();
</code></pre>

<p><a href="http://jsfiddle.net/ptZjD/" rel="nofollow">Whereas this code generates x=9 as output</a></p>

<pre><code>var myobj1 = 
{  
    x:9, 
    myfunction:function()
    {
        if(this === window) 
            alert("x is not Defined");
        else if (this === myobj1)
            alert(this.x);
        else
            alert("Error!");
    }
}

function test()
{
    setTimeout(function()
    {
        myobj1.myfunction()
    },  1000); 
}
</code></pre>

<p>Can someone explain me why "if callback method is not being used in test method then the global window object is being called" and "what is the significance of callback method in this case"?</p>
