set length to variable or calculate length within loop statment
<p>Is it more efficient to declare a variable with another variable's length before doing a for-loop or should the length be calculated within the loop.</p>

<p>I'm certain the answer depends on how big the array is that the length is being calculated it on. I just <em>always</em> see</p>

<pre><code>for ( var i = 1; i &lt;= theVar.length; i++ ) {

}
</code></pre>

<p>but then i was told that it is less resource intensive to do </p>

<pre><code>var theVarLen = theVar.length

for ( var i = 1; i &lt;= theVarLen; i++ ) {

}
</code></pre>

<p>as it avoids the recalculation of the length every iteration. </p>

<p>Or does it depend on specific circumstances so much it's impossible to make a categorical decree?</p>

<p>Or, does it not really matter at all..?</p>

<p>Thanks a bunch!</p>
