What is Lodash?

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

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:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

_.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.

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

_.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:

This widget is not supported in dev-mode. Kindly enable it or run using yarn webapp:dev-widgets.

More functions and information on Lodash can be found in the​ official documentation.

Free Resources

Copyright ©2026 Educative, Inc. All rights reserved