hey guys, recently I attended a session in our company it is about node js. and I heard about the amazing JavaScript library the library named ‘lodash’. which is a popular utility library.

this library existed for a long time but I did not know about this library before. after that, I researched this. then I’m also using this library when I need some utility functions. this is a modular library and in this is the home page.

you will see that the how to install this library in your system, and how to run in a browser and nodeJS environment there is a documentation also

if you click this documentation you will see list of functionalities in side-navbar. there are all the essential methods are described here so you can just use those methods. let’s see a demo.

I’m going to run this lodash function in nodeJS environment, so I’ve installed node and created a new project using.

npm init -y

then I installed lodash by typing

npm install --save lodash

then create an index.js file. that’s all we have to do for setup let’s try out some functionalities.

this is a _.concat function using this we can concatenate things like:-

index.js

//this is how we grab the lodash for our index.js
var _ = require(‘lodash’);
//_concat examplevar arr= [“steve”,”jobs”]var all = _.concat(arr,”CEO of APPLE”,{age:65});console.log(all);

it is a common convention to use underscore when you are going to use Lodash library.

here is the example of _.compact

var _ = require(‘lodash’);//_compact example/*Creates an array with all falsey values removed.The values false, null, 0, “”, undefined, and NaN are falsey.*/var data= _.compact([0, 1, false, 2, ‘’, 3]);console.log(data);

this kind of hundreds of utility methods are defined in this lodash library you can also see in the documentation.

conclusion

just keep your eye open and check out the methods in lodash. when we do projects we need this kind of functionalities so you can just import Lodash. I hope if you did not know about this library before, you can use this library from now on to solve your problems. will see you guys in the next article until then Happy coding!

Software Engineer at hSenid Mobile

Software Engineer at hSenid Mobile