Lodash - Collection


Advertisements

Lodash has many easy to use methods which helps in processing Collections. This chapter discusses them in detail.

Lodash provides various methods to process the Collections as listed below −

Sr.No. Method & Syntax
1

countBy

_.countBy(collection, [iteratee=_.identity])

2

every

_.every(collection, [predicate=_.identity])

3

filter

_.filter(collection, [predicate=_.identity])

4

find

_.find(collection, [predicate=_.identity], [fromIndex=0])

5

findLast

_.findLast(collection, [predicate=_.identity], [fromIndex=collection.length-1])

6

flatMap

_.flatMap(collection, [iteratee=_.identity])

7

flatMapDeep

_.flatMapDeep(collection, [iteratee=_.identity])

8

flatMapDepth

_.flatMapDepth(collection, [iteratee=_.identity], [depth=1])

9

forEach

_.forEach(collection, [iteratee=_.identity])

10

forEachRight

_.forEachRight(collection, [iteratee=_.identity])

11

groupBy

_.groupBy(collection, [iteratee=_.identity])

12

includes

_.includes(collection, value, [fromIndex=0])

13

invokeMap

_.invokeMap(collection, path, [args])

14

keyBy

_.keyBy(collection, [iteratee=_.identity])

15

map

_.map(collection, [iteratee=_.identity])

16

orderBy

_.orderBy(collection, [iteratees=[_.identity]], [orders])

17

partition

_.partition(collection, [predicate=_.identity])

18

reduce

_.reduce(collection, [iteratee=_.identity], [accumulator])

19

reduceRight

_.reduceRight(collection, [iteratee=_.identity], [accumulator])

20

reject

_.reject(collection, [predicate=_.identity])

21

sample

_.sample(collection)

22

sampleSize

_.sampleSize(collection, [n=1])

23

shuffle

_.shuffle(collection)

24

size

_.size(collection)

25

some

_.some(collection, [predicate=_.identity])

26

sortBy

_.sortBy(collection, [iteratees=[_.identity]])

Advertisements