Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34150
| From | Rolf Niepraschk <Rolf.Niepraschk@gmx.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Iterating through an array (special syntax) |
| Date | 2017-10-20 07:55 +0200 |
| Message-ID | <f4thebFqrssU1@mid.individual.net> (permalink) |
| References | (3 earlier) <22557651-daf7-4252-b3a4-c9df083be85c@googlegroups.com> <f4mqfvF9pi1U1@mid.individual.net> <526590a8-1952-4da6-a8cd-525eef79df6f@googlegroups.com> <f4rmr3Fdt6iU1@mid.individual.net> <1876626.bB369e8A3T@PointedEars.de> |
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? I see no much differences (at least with nodejs 8):
#=================================================
#!/usr/bin/env node
var arr = [];
for(var i=0; i<5E7; i++) arr.push(i);
var x, start;
start = new Date().getTime();
for (var i=0; i<arr.length; i++) {};
console.log('A: ' + (new Date().getTime()-start) + ' ms');
start = new Date().getTime();
for (var i=0, len = arr.length; i < len; i++) {};
console.log('B: ' + (new Date().getTime()-start) + ' ms');
#=================================================
>
>> fn_each(oldItems[i], newItems[i]);
>> }
>
> This loop is pointlessly inefficient in any case. You are already using
> Array.prototype.map(), thereby iterating through the array, so you can
> either output or accumulate the old and new value *in the callback*.
Ok.
I will think about your Promise solution. Thanks for your explanation.
...Rolf
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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