Mind boggling Function for Looping
<p>If there's anyone who can help me understand this one, I will be impressed. It's #28 from <a href="http://ejohn.org/apps/learn/#28" rel="nofollow">John Resig's advanced JavaScript</a>.</p>

<p>Here's a function for looping, and, if you look at the tutorial, it seems to run 3 times producing the 6 Pass below. </p>

<p>Can you please explain in plain language in as much detail as possible what is happening in this program, explaining along the way:</p>

<ol>
<li><p><code>fn.call(array, array[i], i)</code>  Why are there these 3 parameters to the function and how do they all work. Does the function first deal with array, then array[i], and then i? What's happening when all that is going on?</p></li>
<li><p>Also, in the function, I understand that <code>i++</code> goes up every time that it goes through the array.length, but what triggers <code>num++</code> to increase it's value, and in what way is <code>value == num++</code></p></li>
<li><p>In <code>function(value, i)</code>, what is <code>value</code>? Is value alternately 0,1,2 of the loop array? If so, how do those loop array numbers get passed as a parameter in <code>function(value, i)</code></p></li>
<li><p><code>this instanceof Array</code>  what is this trying to show?  How?.</p></li>
</ol>

<p>Code:</p>

<pre><code>function loop(array, fn){ 
  for ( var i = 0; i &lt; array.length; i++ ) 
    fn.call( array, array[i], i ); 
} 
var num = 0; 
loop([0, 1, 2], function(value, i){ 
  assert(value == num++, "Make sure the contents are as we expect it."); 
  assert(this instanceof Array, "The context should be the full array."); 
});
</code></pre>

<blockquote>
PASS Make sure the contents are as we expect it.<br/>
PASS The context should be the full array.  <br/>
PASS Make sure the contents are as we expect it. <br/> 
PASS The context should be the full array.  <br/>
PASS Make sure the contents are as we expect it. <br/> 
PASS The context should be the full array.  <br/>
</blockquote>
