DEV Community

Why Should Lodash be Your JavaScript Project's Go-To Library?

WebCraft Notes on February 06, 2024

Check this post on my web notes. In almost every project we work on, we use extra tools to make things easier for users and developers alike. ...
Collapse
 
marco_cabrera_81e1796f41f profile image
marco cabrera

JavaScript has come a long way, now incorporating features like deep copying, which we once depended on libraries like lodash for. Today, using an entire library for such tasks when JavaScript handles them natively might seem unnecessary.

Collapse
 
teamradhq profile image
teamradhq

Yeah but still not for difference, union, unique… and not for the by methods for each of these… Then of course there’s zip and unzip methods too… we haven’t even gotten past the array methods… And don’t get me started on the collection methods.

I think yours is a common misconception though. Lodash is a toolset, it’s not meant to polyfill missing features of JavaScript. Yes some people use it that way. But those people are using a fraction of Lodash’s features.

There are so many common tools - like the ones I’ve mentioned - that are unlikely to be implemented in the JS spec… I doubt we’ll ever see pipe, compose or curry functions, for example.

So I’d caution against writing it off just because JS has added some array methods. And remember, jQuery just dropped the beta for v4 ;)

Collapse
 
webcraft-notes profile image
WebCraft Notes

Thank you for sharing your perspective! You're absolutely right that JavaScript has evolved with native features, including deep copying. While it's true that some lodash functionalities can be replicated with native JavaScript, many developers still find Lodash valuable for its comprehensive utility functions, convenience and ease of use in the development process. Also it often comes down to personal preference and project requirements. Appreciate your input!

Collapse
 
marco_cabrera_81e1796f41f profile image
marco cabrera

I totally get the thing about personal preference. Lots of folks stick to jQuery for DOM manipulation because it’s comfy and speeds things up. I’ve had my fair share of fun with these libraries, so no issues there. But they do gloss over the details, which isn’t always great for newbies. Even though this blog might not be newbie-central, it’s something to think about. It’s all about understanding what’s under the library’s hood — we should be aiming for a ‘deep copy’ of knowledge, not just a ‘shallow copy.’ After all, we wouldn’t want our learning to be as superficial as a shallow clone, would we? Also good article, can’t wait to read your next ones.

Thread Thread
 
webcraft-notes profile image
WebCraft Notes

Thank you for sharing your thoughts! You make a valid point about the importance of delving into the details, especially for newcomers. I'm glad you enjoyed the article, and I'll certainly keep your feedback in mind for future posts. 😊

Collapse
 
blindfish3 profile image
Ben Calder

You can import individual modules from lodash so you can still benefit from it without importing the entire library.

Collapse
 
_ndeyefatoudiop profile image
Ndeye Fatou Diop

💯