and he answered me:
One should never rely on what one cannot know. You cannot know the runtime
environments code once written will be exposed to. There is no good reason
to assume the value of the “length” property should be automatically cached
for a loop in the first place as it could change by statements in the loop.
One can know instead that avoiding to access a property repeatedly whose
value does not change, in favor of a local variable that holds this value,
reduces code complexity. That has a chance – and it has been showed – to
increase runtime efficiency, IOW to be faster. So it is wise to do that.
I must write that I strongly agree with above opinion. However, feel free to write constructive comment here.
Leave a Reply