title: for-loop setting length variable when converting from nodelist
body: <p>phew! That was a long title.</p>
  
  <p>I'm reading WROX' book on Professional JavaScript for web developers and I came across this sample code, and I was just wondering if that was best practice:</p>
  
  <pre><code>function convertToArray(nodes) {
     array = new Array();
     for (var i=0, len=nodes.length; i &lt; len; i++) {
        array.push(nodes[i]);
     }
     return array;
  }
  </code></pre>
  
  <p>The thing that's got me scratching my head is the "len=nodes.length". Am I wrong in thinking that the first sentence in a for-loop is only run once? Is there a reason you'd want to set a variable (len) to the length of the nodeList before running through it? Would you do that to a normal array as well?</p>
  
  <p>Thanks</p>