Lodash Array has many easy-to-use methods which help in processing Arrays. This chapter discusses them in detail.
Lodash provides various methods to process the Arrays as listed below −
Sr.No. | Method & Syntax |
---|---|
1 | chunk_.chunk(array, [size=1]) |
2 | compact_.compact(array) |
3 | concat_.concat(array, [values]) |
4 | difference_.difference(array, [values]) |
5 | differenceBy_.differenceBy(array, [values], [iteratee=_.identity]) |
6 | differenceWith_.differenceWith(array, [values], [comparator]) |
7 | drop_.drop(array, [n=1]) |
8 | dropRight_.dropRight(array, [n=1]) |
9 | dropRightWhile_.dropRightWhile(array, [predicate=_.identity]) |
10 | dropWhile_.dropWhile(array, [predicate=_.identity]) |
11 | fill_.fill(array, value, [start=0], [end=array.length]) |
12 | findIndex_.findIndex(array, [predicate=_.identity], [fromIndex=0]) |
13 | findLastIndex_.findLastIndex(array, [predicate=_.identity], [fromIndex=array.length-1]) |
14 | flatten_.flatten(array) |
15 | flattenDeep_.flattenDeep(array) |
16 | flattenDepth_.flattenDepth(array, [depth=1]) |
17 | fromPairs_.fromPairs(pairs) |
18 | head_.head(array) |
19 | indexOf_.indexOf(array, value, [fromIndex=0]) |
20 | initial_.initial(array) |
21 | intersection_.intersection([arrays]) |
22 | intersectionBy_.intersectionBy([arrays], [iteratee=_.identity]) |
23 | intersectionWith_.intersectionWith([arrays], [comparator]) |
24 | join_.join(array, [separator=’,’]) |
25 | last_.last(array) |
26 | lastIndexOf_.lastIndexOf(array, value, [fromIndex=array.length-1]) |
27 | nth_.nth(array, [n=0]) |
28 | pull_.pull(array, [values]) |
29 | pullAll_.pullAll(array, values) |
30 | pullAllBy_.pullAllBy(array, values, [iteratee=_.identity]) |
31 | pullAllWith_.pullAllWith(array, values, [comparator]) |
32 | pullAt_.pullAt(array, [indexes]) |
33 | remove_.remove(array, [predicate=_.identity]) |
34 | reverse_.reverse(array) |
35 | slice_.slice(array, [start=0], [endropd=array.length]) |
36 | sortedIndex_.sortedIndex(array, value) |
37 | sortedIndexBy_.sortedIndexBy(array, value, [iteratee=_.identity]) |
38 | sortedIndexOf_.sortedIndexOf(array, value) |
39 | sortedLastIndex_.sortedLastIndex(array, value) |
40 | sortedLastIndexBy_.sortedLastIndexBy(array, value, [iteratee=_.identity]) |
41 | sortedLastIndexOf_.sortedLastIndexOf(array, value) |
42 | sortedUniq_.sortedUniq(array) |
43 | sortedUniqBy_.sortedUniqBy(array, [iteratee]) |
44 | tail_.tail(array) |
45 | take_.take(array, [n=1]) |
46 | takeRight_.takeRight(array, [n=1]) |
47 | takeRightWhile_.takeRightWhile(array, [predicate=_.identity]) |
48 | takeWhile_.takeWhile(array, [predicate=_.identity]) |
49 | union_.union([arrays]) |
50 | unionBy_.unionBy([arrays], [iteratee=_.identity]) |
51 | unionWith_.unionWith([arrays], [comparator]) |
52 | uniq_.uniq(array) |
53 | uniqBy_.uniqBy(array, [iteratee=_.identity]) |
54 | uniqWith_.uniqWith(array, [comparator]) |
55 | unzip_.unzip(array) |
56 | unzipwith_.unzipWith(array, [iteratee=_.identity]) |
57 | without_.without(array, [values]) |
58 | xor_.xor([arrays]) |
59 | xorBy_.xorBy([arrays], [iteratee=_.identity]) |
60 | xorWith_.xorWith([arrays], [comparator]) |
61 | zip_.zip([arrays]) |
62 | zipObject_.zipObject([props=[]], [values=[]]) |
63 | zipObjectDeep_.zipObjectDeep([props=[]], [values=[]]) |
64 | zipWith_.zipWith([arrays], [iteratee=_.identity]) |
Next Topic – Click Here