Open In App

Lodash Collection Complete Reference

Last Updated : 20 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Lodash is a JavaScript library that works on the top of underscore.js. Lodash helps in working with arrays, strings, objects, numbers, etc. It provides us with various inbuilt functions and uses a functional programming approach which makes coding in javascript easier to understand because instead of writing repetitive functions, tasks can be accomplished with a single line of code.

Lodash Methods

Description

_.countBy()It creates an object composed of keys generated from the results of running each element of collection through iteratee.
_.every()It checks if the predicate returns true for all elements of collection and iteration is stopped once the predicate returns falsely.
_.filter()It iterates over elements of collection, returning an array of all elements predicate returns true.
_.find()It access each value of the collection and returns the first element that passes a truth test for the predicate.
_.findLast()It iterates over the elements in a collection from the right to the left.
_.flatMap()It creates a flattened array of values by running each element in collection through iteratee and flattens the mapped results.
_.flatMapDeep()It creates a flattened array of values by running each element in collection through iteratee and flattens the mapped results.
_.flatMapDepth()It creates a flattened array of values by running each element in collection through iteratee and flattens the mapped results up to the given depth value.
_.forEach()It iterates over elements of collection and invokes iteratee for each element.
_.forEachRight()It iterates over elements of collection from right to left.
_.groupBy()It creates an object composed of keys generated from the results of running each element of collection through iteratee.
_.includes()It is used to find the value is in the collection or not.
_.invokeMap()It invokes the method at the given path of each element in the collection and returns an array of the results of each invoked method.
_.keyBy()It creates an object that composed of keys generated from the results of running an each element of collection through iteratee.
_.map()It creates an array of values by running each element in collection through the iteratee.
_.orderBy()It allows the sort orders of the iterates to sort by.
_.partition()It creates an array of elements split into two groups.
_.reduce()It reduces collection to value which is accumulated result of running each element in the collection through iteratee.
_.reduceRight()It iterates over elements of collection from right to left.
_.reject()This method returns elements of the collection that predicate does not return true.
_.sample()It will provide a random element from collection.
_.sampleSize()is used to give an array of n random elements from the given array.
_.shuffle()It creates an array of shuffled values from the given collection using a version of the Fisher-Yates shuffle algorithm.
_.size()It gets the size of collection by returning its length for array such as values.
_.some()It is used to check if predicate return true for any element of collection.
_.sortBy()It creates an array of elements which is sorted in ascending order by the results of running each element in a collection through iteratee.

Next Article

Similar Reads