Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #34118
| From | Rolf Niepraschk <Rolf.Niepraschk@gmx.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Iterating through an array (special syntax) |
| Date | 2017-10-17 12:39 +0200 |
| Message-ID | <f4m4ugF4q8tU1@mid.individual.net> (permalink) |
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
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