vendredi 7 mars 2014

Scala "for comprehension" in Javascript


Vote count:

0




I've gotten used to Scala's "for" construct and like it a lot. I am now writing some Javascript code and am using Lo-Dash (basically an extension of Underscore). Is there any way to mimic Scala's "for" comprehension in javascript?


My goal is to clean map/reduce code similar to this:



rawCoordinates = _.map( directionsRoute.legs, function ( leg ) {
return _.map( leg.steps, function ( step ) {
return _.map( step.path, function ( latLng ) {
return [ latLng.lng(), latLng.lat() ];
} );
} );
} );


Thanks!



asked 56 secs ago

Jon

3,780





Aucun commentaire:

Enregistrer un commentaire