David Bruant (2013-07-16T19:45:03.000Z)
domenic at domenicdenicola.com (2013-07-19T15:39:28.785Z)
Le 16/07/2013 19:54, Claus Reinke a écrit : > ```js > // this doesn't work > function* generator(){ > [1,2,3].forEach( function(x){ yield x } ) > } > ``` I have been thinking and with for..of, I can't find a good reason to use .forEach instead of for..of. for..of does what you need here with generators too. > For the specific case of forEach et al What do you mean by "et al"? I don't believe .map, .reduce or .filter are any interesting to use alongside generators. Even if so, for..of can work too and is decently elegant (YMMV): function* g(){ [1,2,3].map(x => {yield transform(x)}) } becomes function* g(){ for(x of [1,2,3]) yield transform(x); }