4 ms·
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
by terabytest 13y ago
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.
- coldtea 13y agoThe library is a few K, which is nothing, and it's not "just for that", it's a veritable utility belt with lots of other utilities.
- declandewet 13y agoAgreed. 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)
- spikels 13y agoBut 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. http://kangax.github.io/es5-compat-table/ http://kangax.github.io/es5-compat-table/
- joelhooks 13y agoIt 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.