In many projects, you may see the following function.

_.each([1, 2], function(value) {
  console.log(value);
});
Copy the code

And then you’re confused about what this is all about, right?

Then go to the top of the page and you might see the following sentence:

import * as _ from 'lodash';

Lodash library

The above sentence indicates that you are using the Lodash library in your project.

Lodash is a consistent, modular, high-performance JavaScript utility library.

In a nutshell, this library is similar to JQuery, which allows you to quickly select elements in HTML. As you all know, JQuery’s default call function uses $.

Lodash can do some quick operations on the types of data you need. The official website is lodash.com/.

For example, in the code above, you can iterate over an array using a function.

Otherwise, you might need to write your own for, which seems like a bit of a hassle.

Lodash makes things a lot easier. You can also search for existing methods on the official website.

Usually, some examples are provided, but you may also need to do specific debugging for your own data.

www.ossez.com/t/lodash/13…