Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.mixmin.net!weretis.net!feeder4.news.weretis.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <3009252.vL9dYu562Q@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Tue, 25 Jun 2013 23:03:03 +0200 User-Agent: KNode/4.10.4 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <2496880.a6ciHIckR8@PointedEars.de> MIME-Version: 1.0 Lines: 30 NNTP-Posting-Date: 25 Jun 2013 23:03:04 CEST NNTP-Posting-Host: eb703e26.newsspool4.arcor-online.net X-Trace: DXC=>]CmDG8W3^:85[]]\]T0814IUK]gf>eL58o?d5DT1 X-Complaints-To: usenet-abuse@arcor.de Xref: csiph.com comp.lang.javascript:20441 Cezary Tomczyk wrote: > On 2013-06-25 03:06, Thomas 'PointedEars' Lahn wrote: > [...] >> Safer and more efficient: >> >> for (var i = 0, len = Aarray.length; i < len; ++i) >> { > > By the way of above. According to discussion here > http://stackoverflow.com/questions/6261953/do-modern-javascript-jiters-need-array-length-caching-in-loops > in your opinion property "length" still needs to be stored in variable > before loop? Or this can be omitted because modern browsers caching (?) > "length" property? 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. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.