3 ms·
Indeed. Personally I'm used to think in functional ways: map, fold, function composition, immutability... I'd like to be good at Haskell but I'm always having l
by mdup 11y ago
Indeed. Personally I'm used to think in functional ways: map, fold, function composition, immutability... I'd like to be good at Haskell but I'm always having lots of pain dealing with it, because I never see the end of the learning curve.
I've found JS to be a nice middle land where I can get productive functionally without too much hassle. It's like a good friend who understands my way of thinking without being in the way too much. Underscore.js hits the sweet spot for me: _.chain(...).map(...).filter(...).value() is verbose but surprinsingly readable. I'm not a fan of Python map() syntactically, and I absolutely hate C++11's std::transform.
- notduncansmith 11y agoIf you want to make that even less verbose, try myArray.map(...).filter(...) (those methods don't have to come from underscore, they exist on the Array prototype as of ES5).