Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #20441
| 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> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <usenet@PointedEars.de> |
| 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+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: Looping holding old copy of array |
| Newsgroups | comp.lang.javascript |
| References | <6870a10e-ea81-40d5-91f8-ce425152e543@googlegroups.com> <XnsA1E963239D075eejj99@194.109.133.133> <f9fdda94-c977-42f5-af79-89a5d2155a85@googlegroups.com> <2496880.a6ciHIckR8@PointedEars.de> <kqcsf3$82s$1@dont-email.me> |
| 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<Cl32<14Fo<]lROoR18kF<OcfhCO;j]Fh:bfXX[=DZm8W4\YJN<b@mF9jNikd57a5\<`>]gf>eL58o?d5DT1 |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.javascript:20441 |
Show key headers only | View raw
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.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Looping holding old copy of array jonas.thornvall@gmail.com - 2013-06-23 22:50 -0700
Re: Looping holding old copy of array "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-06-24 09:44 +0200
Re: Looping holding old copy of array "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-06-24 16:45 -0700
Re: Looping holding old copy of array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-25 03:06 +0200
Re: Looping holding old copy of array Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2013-06-25 21:58 +0200
Re: Looping holding old copy of array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-06-25 23:03 +0200
Re: Looping holding old copy of array JJ <duh@nah.meh> - 2013-06-24 15:19 +0700
Re: Looping holding old copy of array jonas.thornvall@gmail.com - 2013-06-24 03:38 -0700
Re: Looping holding old copy of array JJ <duh@nah.meh> - 2013-06-25 10:52 +0700
csiph-web