Re:Google Closure: How not to write Javascript
by mark_h on Thursday November 12, 2009 @12:58AM
(#937234)
I wondered that too. I wonder if they just don't notice it because the modern VMs they mainly use would cache or inline it, but older implementations do a search for the property each time? (I'm speculating on both those points)
[ Parent
| on HN ]
Re:Google Closure: How not to write Javascript
by nostrademons on Thursday November 12, 2009 @01:05AM
(#937239)
I think it's an oversight. The coding conventions I work with ban that form of a for-loop, precisely because the .length access can potentially be very costly. (I'm in a different part of the company, one that doesn't use Closure, but our latency constraints are even tighter than theirs are.) If you're iterating over a NodeList and not just an array, it can actually turn an O(N) loop into an O(N^2) one.