What is Lodash?
Installation
Lodash can be installed via NPM:
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.
Functions
Some handy functions included in Lodash are:
_.concat()
The _.concat() function simply concatenates values to an existing array, as shown below:
_.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. Moreover, it can be used to find an object using multiple properties.
_.intersection
The normal code, to find the common elements between two arrays, uses a for loop with several lines of code. In Lodash, this is achieved in a single line with the _.intersection() function:
More functions and information on Lodash can be found in the official documentation.
Free Resources