Hacker News new | ask | show | jobs
by Sarien 4154 days ago
Q: "What does it do?"

A: "A utility library delivering consistency, modularity, performance, & extras."

Q: "Yeah, but what does it do?"

A: "Oh, nothing but it does it consistently, modularly and performant. We also have functions for string handling in the extras module."

2 comments

It's extra stuff that should be in the standard library but isn't.

These days, a lot of it is actually in the standard library - for example, array maps - and invoking lodash just calls the es5/es6 built in, with a slightly uglier syntax.

But if you want backward compatibility, you still probably want to use something like Lodash. I'd also argue that Lodash's/Underscore's interface is far better thought out than the standard library. The standard library has so many absurd gotchas, like `["2", "2", "2", "2"].map(parseInt)`. The verbosity of Javascripts lambdas also makes composition of simple parts more arcane looking than necessary, and having a whole bunch of composable/chainable utility functions does a lot to help people write self-documenting code.
> But if you want backward compatibility, you still probably want to use something like Lodash.

A few years ago, sure, but these days I'd use es6-shim. The code will be shorter, have more documentation around the internet, and when old browsers die you won't have to change anything to be on standard JS.

lodash offers features and performance over es5/6 built-ins.
Interestingly, in practice lo-dash actually doesn't proxy through to the native implementation for things like map and forEach. Just using loops ends up being more performant because of some edge cases in the ES5 spec for those methods that lo-dash and underscore don't follow.

http://benmccormick.org/2014/11/12/underscore-vs-lodash/

The most important feature is chaining and lazy evaluation.

I think the most useful functions are the typechecking utilities (typeof in javascript is the most useless keyword the human kind engineered in a language).

In the end is a very nice library to work with when it does not get in the way (of course, if you are using `_.each([], fn)`, you should think again and use `Array#forEach` or a nice `for`)

>of course, if you are using `_.each([], fn)`, you should think again and use `Array#forEach` or a nice `for`

You probably shouldn't if you're in a hot path. LoDash actually outperforms some native ES5 features, Array#forEach being one of them IIRC.

It should start being called "the jQuery effect" since it's one of those libraries that comes to be considered by the community as a standard way to patch the environment. Not only that, but some people begin to develop very strong, quirky aesthetic preferences for seeing it in their code.
I also had no idea what this was until I got to the bottom of the page. Looks like a "better underscore.js". They should just say something to that effect upfront.
They used too say that when the project was new. Perhaps now they feel the project is established enough that it can stand on it's own without trying to position it as a drop-in replacement for underscore.