Better HN
topnewbestaskshowjobs
Log inSign up

maroshii

1 karma · joined Jul 7, 2015 (11y ago) · 1 submissions

Submissions

comment 11y ago · link · parent

One of the advantages of underscore (and lodash) is that you can iterate over arrays AND objects indistinctly in most cases. How would you do:

  var a1b2 = _.reduceRight({a:1,b:2},(memo,val,key) => key+val+memo,'');
or:

  var two = _.find({a:2,b:3,c:4},(val,key) => key !== 'a' && key !== 'c' )
Until I see _.chain, _.compose, _.partialRight, _.zip or _.throttle (among others) implemented in the standard library lodash is a no-opt.

With iterables and the "for of" loop javascript is definitely not going in the direction of functional programming though.