Taking Lodash off the Down Low for New Devs
Another Tool for Your Javascript Belt

What is Lodash?
Let’s talk about one of the most popular and heavily downloaded npm packages. Lodash is a JavaScript library that provides built in functions for common programming tasks by using a functional programming paradigm; it builds upon the older underscore.js library. The Lodash built-in utility functions make coding in JavaScript easier and cleaner. Instead of writing common repetitive functions, the task can be accomplished with a single line of code after importing the package.

Installation is Easy
Lodash can be installed via NPM or Yarn:
npm install --save lodash
After installation is complete, Lodash can be imported into a JavaScript file as:
import _ from "lodash"
Now, all of Lodash’s functions can be accessed by the underscore operator.
Here’s an example using the _.concat() function, more about that shorty
let arr = ['dog', 'cat', 'bird', 'hamster']let arr = _.concat(arr, 'zebra', 'snake');// Output => arr = ['dog', 'cat', 'bird', 'hamster', 'zebra', 'snake']
Pros
- It’s very readable. The function names are very human friendly with names like
— — — times( ) - as the name implies, this does something x amount of times
— — — omit( )- deletes someithing from an update
— — — compact( )- removes falsey values from arguments passed in
— — — concat( )- concatenates values onto an existing array
— — — find( )- Instead of using a loop to iterate through an array to search for an object, the _.find()
function can perform the same task in a single line. In fact, it can be used to find an object using multiple properties.
- Delegating maintenance of this function to a well maintained package.
- You’re not really compromising much performance when implementing Lodash.


- shorter code, you could be writing the same functions in one liners.

- you can chain functions explicitly or implicitly to do nested arithmetic

- Lastly, one of the great benefits you get from using Lodash is that unlike some of the native .js functions, Lodash functions are supported in every browser
Hope you Learned Something!
As always I would love to hear from you the reader. If you have any feedback or questions, don’t hesitate to reach out.