Lodash
What is Lodash?
Lodash is a JavaScript library that works on the top of underscore.js. It helps in working with arrays, strings, objects, numbers, etc. It provides us with various inbuilt functions and uses a functional programming approach which that coding in JavaScript easier to understand because instead of writing repetitive functions, tasks can be accomplished with a single line of code. It also makes it easier to work with objects in JavaScript if they require a lot of manipulation to be done on them.
Why Lodash?
It provides various inbuilt functions for collections, arrays, manipulated objects, and other utility methods that we can use directly instead of writing them from scratch. It makes it easier to iterate over the arrays, strings as well as objects. Its modular methods make the creation of composite functions easier.
What is Lodash npm ?
The Lodash npm is used to install and import Lodash library using npm module. The command for installation of Lodash using npm module is npm i lodash
How to Install Lodash ?
Lodash library can be used directly using the CDN link or can be installed using npm or yarn.
Using CDN Link
We can directly use the file in the browser. Go to the official documentation and copy the lodash.min.js file CDN link and paste this link inside the head section.
<script type=”text/JavaScript” src = “https://cdn.jsdelivr.net/npm/lodash@4.17.20/lodash.min.js”></script>
Installation using npm
npm install lodash
If you are using yarn then you can use the following command:
yarn install lodash
Now in order to use the Lodash library, you need to require it in the code file.
const _ = require("lodash");
Now let’s understand how to use Lodash with the help of the code example.
Learn more about Lodash
Lodash Array Methods
- Lodash _.chunk() Method
- Lodash _.compact() Method
- Lodash _.concat() Method
- Lodash _.difference() Method
- Lodash _.differenceBy() Method
- Lodash _.differenceWith() Method
- Lodash _.drop() Method
- Lodash _.dropRight() Method
- Lodash _.dropRightWhile() Method
- Lodash _.dropWhile() Method
- Lodash Array Complete Reference
- Lodash _.fill() Method
- Lodash _.findIndex() Method
- Lodash _.findLastIndex() Method
- Lodash _.first() Method
- Lodash _.flatten() Method
- Lodash _.flattenDepth() Method
- Lodash _.flattenDeep() Method
- Lodash _.fromPairs() Method
- Lodash _.head() Method
- Lodash _.indexOf() Method
Lodash Collection Methods
- Lodash _.countBy() Method
- Lodash _.every() Method
- Lodash _.filter() Method
- Lodash _.find() Method
- Lodash _.findLast() Method
- Lodash _.flatMap() Method
- Lodash _.flatMapDeep() Method
- Lodash _.flatMapDepth() Method
- Lodash _.forEach() Method
- Lodash _.forEachRight() Method
- Lodash _.groupBy() Method
- Lodash _.includes() Method
- Lodash _.invokeMap() Method
- Lodash _.keyBy() Method
- Lodash _.map() Method
- Lodash _.orderBy() Method
- Lodash _.partition() Method
- Lodash _.reduce() Method
- Lodash _.reduceRight() Method
- Lodash _.reject() Method
- Lodash Collection Complete Reference
Lodash Functions
- Lodash _.after() Method
- Lodash _.ary() Method
- Lodash _.before() Method
- Lodash _.bind() Method
- Lodash _.bindKey() Method
- Lodash _.curry() Method
- Lodash _.curryRight() Method
- Lodash _.debounce() Method
- Lodash _.defer() Method
- Lodash _.delay() Method
- Lodash _.flip() Method
- Lodash _.memoize() Method
- Lodash _.negate() Method
- Lodash _.once() Method
- Lodash _.overArgs() Method
- Lodash _.partial() Method
- Lodash _.partialRight() Method
- Lodash _.rearg() Method
- Lodash _.rest() Method
- Lodash _.spread() Method
- Lodash _.throttle() Method
- Lodash _.wrap() Method
- Lodash Function Complete Reference
Lodash Lang Methods
- Lodash _.castArray() Method
- Lodash _.clone() Method
- Lodash _.cloneDeep() Method
- Lodash _.cloneDeepWith() Method
- Lodash _.cloneWith() Method
- Lodash _.conformsTo() Method
- Lodash _.eq() Method
- Lodash _.gt() Method
- Lodash _.gte() Method
- Lodash _.isArguments() Method
- Lodash _.isArray() Method
- Lodash _.isArrayBuffer() Method
- Lodash _.isArrayLike() Method
- Lodash _.isArrayLikeObject() Method
- Lodash _.isBoolean() Method
- Lodash _.isBuffer() Method
- Lodash _.isDate() Method
- Lodash _.isElement() Method
- Lodash _.isEmpty() Method
- Lodash _.isEqual() Method
- Lodash Lang Complete Reference
Lodash Math Methods
- Lodash _.add() Method
- Lodash _.ceil() Method
- Lodash _.divide() Method
- Lodash _.floor() Method
- Lodash _.max() Method
- Lodash _.maxBy() Method
- Lodash _.mean() Method
- Lodash _.meanBy() Method
- Lodash _.min() Method
- Lodash _.minBy() Method
- Lodash _.multiply() Method
- Lodash _.round() Method
- Lodash _.subtract() Method
- Lodash _.sum() Method
- Lodash _.sumBy() Method
- Lodash Math Complete Reference
Lodash Object Methods
- Lodash _.assign() Method
- Lodash _.assignIn() Method
- Lodash _.assignInWith() Method
- Lodash _.assignWith() Method
- Lodash _.at() Method
- Lodash _.create() Method
- Lodash _.defaults() Method
- Lodash _.defaultsDeep() Method
- Lodash _.entries() Method
- Lodash _.entriesIn() Method
- Lodash _.extend() Method
- Lodash _.extendWith() Method
- Lodash _.findKey() Method
- Lodash _.findLastKey() Method
- Lodash _.forIn() Method
- Lodash _.forInRight() Method
- Lodash _.forOwn() Method
- Lodash _.forOwnRight() Method
- Lodash _.functions() Method
- Lodash _.functionsIn() Method
- Lodash Object Complete Reference
Lodash Seq Methods
- Lodash _.chain() Method
- Lodash _.tap() Method
- Lodash _.thru() Method
- Lodash _.prototype[Symbol.iterator]() Method
- Lodash _.prototype.at() Method
- Lodash _.prototype.chain() Method
- Lodash _.prototype.commit() Method
- Lodash _.prototype.next() Method
- Lodash _.prototype.plant() Method
- Lodash _.prototype.reverse() Method
- Lodash _.prototype.toJSON() Method
- Lodash _.prototype.value() Method
- Lodash _.prototype.valueOf() Method
- Lodash Seq Complete Reference
Lodash String Methods
- Lodash _.camelCase() Method
- Lodash _.capitalize() Method
- Lodash _.deburr() Method
- Lodash _.endsWith() Method
- Lodash _.escape() Method
- Lodash _.escapeRegExp() Method
- Lodash _.kebabCase() Method
- Lodash _.lowerCase() Method
- Lodash _.lowerFirst() Method
- Lodash _.pad() Method
- Lodash _.padEnd() Method
- Lodash _.padStart() Method
- Lodash _.parseInt() Method
- Lodash _.repeat() Method
- Lodash _.replace() Method
- Lodash _.snakeCase() Method
- Lodash _.split() Method
- Lodash _.startCase() Method
- Lodash _.startsWith() Method
- Lodash _.template() Method
- Lodash String Complete Reference
Lodash Util Methods
- Lodash _.bindAll() Method
- Lodash _.cond() Method
- Lodash _.conforms() Method
- Lodash _.constant() Method
- Lodash _.defaultTo() Method
- Lodash _.flow() Method
- Lodash _.flowRight() Method
- Lodash _.identity() Method
- Lodash _.iteratee() Method
- Lodash _.matches() Method
- Lodash _.matchesProperty() Method
- Lodash _.method() Method
- Lodash _.methodOf() Method
- Lodash _.noConflict() Method
- Lodash _.noop() Method
- Lodash _.nthArg() Method
- Lodash _.over() Method
- Lodash _.overEvery() Method
- Lodash _.overSome() Method
- Lodash _.property() Method
- Lodash Util Complete Reference