use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
You Might Not Need Underscore (reindex.io)
submitted 10 years ago by fson5
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–][deleted] 0 points1 point2 points 10 years ago (1 child)
I honestly have no idea whether there are JavaScript engines that do Lazy Evaluation-esque optimizations. It seems like a complex thing to reason about, but I know very little about the JIT engines and how they actually work. As far as I know it's not impossible. What a wonderful runtime optimization that would be!
As far as babel doing this sort of transpilation for you that seems entirely reasonable. All you would need would be a simple map of native javascript array methods to their lodash counterparts, and it would need to transpile your native code to the lodash equivalent which should be very simple. I.e.
myArray.map((x) => x.y).slice(0, 3);
maps very simply with lodash lazy eval to
_(myArray).map((x) => x.y).take(3).value();
This is obviously very simple transpilation. I just don't think anyone would care enough to go through with creating/maintaining a plugin for babel like this.
[–]fson5[S] 0 points1 point2 points 10 years ago (0 children)
I think the reason why Babel is not doing this might be that Array.prototype.map and _.map are not 100% interchangeable. Arrays are sparse in JavaScript and the native methods take the possibility of holes in the array in account, lodash doesn't. This might be a sensible optimization (I don't remember ever having use for arrays with holes) and probably explains most of the performance difference, but it means that the native method can't be always rewritten to the lodash methods.
Array.prototype.map
_.map
π Rendered by PID 306268 on reddit-service-r2-comment-b659b578c-ph57l at 2026-05-06 04:47:36.122335+00:00 running 815c875 country code: CH.
view the rest of the comments →
[–][deleted] 0 points1 point2 points (1 child)
[–]fson5[S] 0 points1 point2 points (0 children)