Changing the context of a function in JavaScript
<p>This is taken from John Resig`s Learning Advanced Javascript #25, called changing the context of a function. </p>

<p>1) in the line <code>fn() == this</code> what does this refer to? is it referring to the this inside the function where it says return this? </p>

<p>2) although I understand the purpose of the last line (to attach the function to a specific object), I don't understand how the code does that.  Is the word "call" a pre-defined JavaScript function? In plain language, please explain "fn.call(object)," and explicitly tell me whether the object in parens <code>(object)</code> is the same object as the <code>var object</code>.  </p>

<p>3). After the function has been assigned to the object, would you call that function by writing <code>object.fn();</code> ?</p>

<pre><code>var object = {}; 
function fn(){ 
  return this; 
} 
assert( fn() == this, "The context is the global object." ); 
assert( fn.call(object) == object, "The context is changed to a specific object."
</code></pre>
