Javascript: obj.fn() vs x=obj.fn;x()
<p>Take a look at this snippet:</p>

<pre><code>var obj = {
    fn: function () {return this;}
};
var x = obj.fn;    

obj.fn();  // returns obj
x();  // returns window (in the browser)
</code></pre>

<p>I'm curious why <code>obj.fn()</code> is different from <code>x=obj.fn; x()</code>. Is there a special case for attribute lookup directly followed by a function call within a single expression - or there is some more complex magic going on under the hood (like with <a href="http://docs.python.org/reference/datamodel.html#implementing-descriptors" rel="nofollow">descriptor protocol</a> in Python) ?</p>
