i’m doing some javascript coding and I was wondering if the length method is “precomputed”, or remembered by the JS engine.
So, the question is:
If I’m checking really often for an array length, and supposing that i’m not changing it (making it immutable through a closure), should I precompute the length method and store it in some variable?
Thanks!
All major interpreters provide efficient accessors for the lengths of native arrays, but not for array-like objects like
NodeLists."Efficient looping in Javascript"
"Efficient JavaScript code" suggests