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.
I'm certain the answer depends on how big the array is that the length is being calculated it on. I just always see
for ( var i = 1; i <= theVar.length; i++ ) {
}
but then i was told that it is less resource intensive to do
var theVarLen = theVar.length
for ( var i = 1; i <= theVarLen; i++ ) {
}
as it avoids the recalculation of the length every iteration.
Or does it depend on specific circumstances so much it's impossible to make a categorical decree?
Or, does it not really matter at all..?
Thanks a bunch!