On 18/02/11 17:00, Peter van der Zee wrote:
The *only* real perf-wise *reason to cache* the length of the array you're
iterating *is* for a *live-query* such as dom queries. For regular arrays,
it really just is not worth the extra variable.
...
I hate it when people say you should cache
Have a read of this
http://blog.getify.com/2011/02/pre-maturely-optimize-revisited/ by @Getify
where he talks about 'im/mature' optimisation and his thoughts on this
discussion.
Personally, I think that it's such a minor tweak that I will always cache
the array length. Why wouldn't you? It
On 18 February 2011 15:12, Mark McDonnell storm.m...@gmail.com wrote:
Have a read of this
http://blog.getify.com/2011/02/pre-maturely-optimize-revisited/ by @Getify
where he talks about 'im/mature' optimisation and his thoughts on this
discussion.
Personally, I think that it's such a minor
As far as readability is concerned I personally don't find it confusing or
any harder to read, but like you say, the more you use the syntax the more
accommodating it appears.
Also, as per any discussions on performance, caching the length of an array
may not seem like a big time save until you
On Fri, Feb 18, 2011 at 4:04 PM, Nick Morgan skilldr...@gmail.com wrote:
Whenever I show anyone code like this though, they say you should cache
the length property - you're looking it up on each iteration. So, what do
you guys think? To me, the second option smacks of premature optimisation.
On Fri, Feb 18, 2011 at 4:04 PM, Nick Morgan skilldr...@gmail.com wrote:
Hi all
This is something I've come across a lot, and I was wondering people's views
on it.
When I'm looping through an array I generally do either this:
var arr = [1, 2, 3, 4];
for (var i = 0; i arr.length; i++) {
On Fri, Feb 18, 2011 at 8:00 AM, Peter van der Zee jsment...@qfox.nlwrote:
The *only* real perf-wise *reason to cache* the length of the array you're
iterating *is* for a *live-query* such as dom queries. For regular arrays,
it really just is not worth the extra variable.
That's much too