In today’s post we will analyze the advantages of using Lodash Libraries, a modern Library of JavaScript utilities that is currently giving us a lot to talk about. Let’s take a look!

What is a Lodash Library?

Lodash is a reference library made with JavaScript. In addition, it’s the most famous successor of underscore.js.

It is used for simplifying the handling and edition of objects, arrangements, etc. since this provides many useful methods to do so. At the same time, simplifying this work achieving that our code be much legible and easy to follow for third parties.

As we said previously,  Lodash is the most famous successor of underscore.js. At first it was a simple “fork” and more features were added.

To this day it has been completely redesigned.

You have the information in GitHub over here.

You have all the documentation over here.

Installation of Lodash

  • Web Navigator

  • NPM

  • Use in NodeJS (In our Node file, we charge the component)

Traditional way vs Lodash

Then, we are going to take a look of some examples about how certain functions are executed with Lodash.

  1. Return the value of a key of the first item of an array that is the value of another key:
  2. Get random number between two numbers:
  3. Extend object:
  4. Get last element:

Conclusion

Lodash is, without a doubt, an extremely useful library. I would continue to use it in all of my NodeJS project.

The advantages that stand out the most is the reduced number of repetitive codes and the improved quality of application logic.

However, what has helped me the most has been the ability to think in a more functional way. I shred my application into smaller modules with a singular focus and no side effects.

This modularity also allows me to write a higher quality code.