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


Groups > comp.lang.javascript > #34118

Iterating through an array (special syntax)

Path csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Rolf Niepraschk <Rolf.Niepraschk@gmx.de>
Newsgroups comp.lang.javascript
Subject Iterating through an array (special syntax)
Date Tue, 17 Oct 2017 12:39:12 +0200
Lines 35
Message-ID <f4m4ugF4q8tU1@mid.individual.net> (permalink)
Reply-To Rolf.Niepraschk@gmx.de
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net DTeqqdx7gm1kHUVX7RlPAgUuPrv7IsQB0vSbiFbqvrCcQ6XdnH
Cancel-Lock sha1:jqgeX8tmBWd7rfcAVTHKyIXaFZc=
X-Mozilla-News-Host news://news.individual.de:119
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0
Content-Language en-US
Xref csiph.com comp.lang.javascript:34118

Show key headers only | View raw


Hello,

I search for a function with the following characteristics:
--------------------------
function foo(arr) {
/* unknown implementation */
}

Call:

foo([1,2,3,4])
.each(function(oldItem, newItem) {
   console.log('old: ' + oldItem + '   ' + 'new: ' + newItem);
   // should be:
   // old: 1   new: 2
   // old: 2   new: 4
   // old: 3   new: 6
   // old: 4   new: 8
})
.done(function(result) {
   console.log('Result: ' + result);// should be: [2,4,6,8]
}
--------------------------
The names "each" and "done" are not important. The static array is an 
example. In reality the array is the result of a network request inside 
of the function.

What would be the best implementation? Thanks in advance.

...Rolf




Back to comp.lang.javascript | Previous | Next — 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