JavaScript closure problem please explain
<p>This is a function taken from Pro JavaScript techniques that I'm trying to understand, but don't. The purpose of the function is to slowly reveal a hidden element by increasing its height over a matter of one second. The comments in the code are provided by the author of the book. I don't understand anything starting from where the author says in a comment "a closure to make sure we have the right 'i'. </p>

<p>Could you please explain in as much detail as possible</p>

<p>a) how does this closure work in this function. I.e. how does it make sure that it has the right 'i' and what in the code makes that important.</p>

<p>b) why is there a comma near the end of the program after elem in the code <code>elem,.style.height</code></p>

<p>c) what is the purpose of this part of the code ( pos + 1) * 10). How does it work with the setTimeout function?</p>

<pre><code>function slideDown(elem) {
  //start the slide down at 0
  elem.style.height = '0px';

    //Show the element, but can`t see it because height is 0
   show(elem);

    //find the full potential height of the element
    var h = fullHeight(elem);

   //We`re going to do a 20 frame animation that takes place over one second
   for (var i = 0; i &lt;= 100; i +=5 ) {
         //a closure to make sure that we have the right 'i'
         (function() {
           var pos = i;

          //set the timeout to occur at the specified time in the future
          setTimeout(function() {

            //set the new height of the element
             elem,.style.height = (pos/100) * h) + "px";

         }, ( pos + 1) * 10);
       })();
     }
}
</code></pre>
