Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #34151

Re: Iterating through an array (special syntax)

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Iterating through an array (special syntax)
Date 2017-10-20 21:48 +0200
Organization PointedEars Software (PES)
Message-ID <1553669.BRYDE4hZ6a@PointedEars.de> (permalink)
References (4 earlier) <f4mqfvF9pi1U1@mid.individual.net> <526590a8-1952-4da6-a8cd-525eef79df6f@googlegroups.com> <f4rmr3Fdt6iU1@mid.individual.net> <1876626.bB369e8A3T@PointedEars.de> <f4thebFqrssU1@mid.individual.net>

Show all headers | View raw


Rolf Niepraschk wrote:

> Am 19.10.2017 um 21:53 schrieb Thomas 'PointedEars' Lahn:
>> Unless oldItems.length changes,
>> 
>>    for (var i=0, len = oldItems.length; i < len; i++) {
>> 
>> is more efficient.
> 
> Are you sure?

Yes.  It is most obvious in the DOM.

> I see no much differences (at least with nodejs 8):
> [test with an *empty* loop over only 100'000 elements]

That does not mean anything; for example, sometimes internal optimization 
will take place, too.  Your empty loops are prime candidates for internal 
optimization to begin with.

My statement is true in general (as a rule of thumb), and if you think more 
carefully about it (i.e., how the “for” command works), you will realize 
why.

> I will think about your Promise solution. Thanks for your explanation.

You’re welcome.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
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


Thread

Iterating through an array (special syntax) Rolf Niepraschk <Rolf.Niepraschk@gmx.de> - 2017-10-17 12:39 +0200
  Re: Iterating through an array (special syntax) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-10-17 05:54 -0700
    Re: Iterating through an array (special syntax) Rolf Niepraschk <Rolf.Niepraschk@gmx.de> - 2017-10-17 15:03 +0200
      Re: Iterating through an array (special syntax) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-10-17 06:19 -0700
        Re: Iterating through an array (special syntax) Rolf Niepraschk <Rolf.Niepraschk@gmx.de> - 2017-10-17 18:46 +0200
          Re: Iterating through an array (special syntax) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-18 13:55 +0200
            Re: Iterating through an array (special syntax) Rolf Niepraschk <Rolf.Niepraschk@gmx.de> - 2017-10-18 14:25 +0200
              Re: Iterating through an array (special syntax) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2017-10-18 15:38 +0200
              Re: Iterating through an array (special syntax) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-18 15:49 +0200
          Re: Iterating through an array (special syntax) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2017-10-18 16:25 -0700
            Re: Iterating through an array (special syntax) Rolf Niepraschk <Rolf.Niepraschk@gmx.de> - 2017-10-19 07:50 +0200
            Re: Iterating through an array (special syntax) Rolf Niepraschk <Rolf.Niepraschk@gmx.de> - 2017-10-19 15:15 +0200
              Re: Iterating through an array (special syntax) Julio Di Egidio <julio@diegidio.name> - 2017-10-19 06:36 -0700
                Re: Iterating through an array (special syntax) Julio Di Egidio <julio@diegidio.name> - 2017-10-19 06:39 -0700
                Re: Iterating through an array (special syntax) Rolf Niepraschk <Rolf.Niepraschk@gmx.de> - 2017-10-19 18:16 +0200
                Re: Iterating through an array (special syntax) Julio Di Egidio <julio@diegidio.name> - 2017-10-19 18:55 -0700
              Re: Iterating through an array (special syntax) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-19 21:53 +0200
                Re: Iterating through an array (special syntax) Rolf Niepraschk <Rolf.Niepraschk@gmx.de> - 2017-10-20 07:55 +0200
                Re: Iterating through an array (special syntax) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-20 21:48 +0200
  Re: Iterating through an array (special syntax) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2017-10-18 04:50 +0200

csiph-web