Re:Stop writing For loops. Start using underscore.
by terabytest on Thursday February 06, 2014 @03:21AM
(#7189284)
This doesn't make much sense. I think this would only make sense if each and map were actual language constructs, like for example in Ruby, but in this case you're bringing in an entire library just for that and that's a bit gross and pointless.
[ Parent
| on HN ]
Re:Stop writing For loops. Start using underscore.
by spikels on Thursday February 06, 2014 @03:50AM
(#7189368)
But they are in Javascript! Both map and forEach were added in 2009 as part of ES5. Problem is they weren't supported in IE until IE9.
Re:Stop writing For loops. Start using underscore.
by declandewet on Thursday February 06, 2014 @03:43AM
(#7189345)
Agreed. Plus, underscore's implementations are not as fast as their native equivalents. At least use lodash if you're going to be using an entire library, as it is faster. Otherwise, you could just use the .reduce, .forEach, and .map constructs that are built into JavaScript (of course browser support is an issue there - but they are available for use in most modern browsers and definitely in node)
Re:Stop writing For loops. Start using underscore.
by joelhooks on Thursday February 06, 2014 @01:32PM
(#7192033)
It makes a lot of sense for the apps I work on. Obviously YMMV, depending on your needs and use case. JS has native implementations of several of the underscore methods, but you get into shims which is even grosser. I'll take consistency any day.