Lodash – Array
”;
Lodash has many easy to use methods which helps 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(array, [size=1]) |
2 |
_.compact(array) |
3 |
_.concat(array, [values]) |
4 |
_.difference(array, [values]) |
5 |
_.differenceBy(array, [values], [iteratee=_.identity]) |
6 |
_.differenceWith(array, [values], [comparator]) |
7 |
_.drop(array, [n=1]) |
8 |
_.dropRight(array, [n=1]) |
9 |
_.dropRightWhile(array, [predicate=_.identity]) |
10 |
_.dropWhile(array, [predicate=_.identity]) |
11 |
_.fill(array, value, [start=0], [end=array.length]) |
12 |
_.findIndex(array, [predicate=_.identity], [fromIndex=0]) |
13 |
_.findLastIndex(array, [predicate=_.identity], [fromIndex=array.length-1]) |
14 |
_.flatten(array) |
15 |
_.flattenDeep(array) |
16 |
_.flattenDepth(array, [depth=1]) |
17 |
_.fromPairs(pairs) |
18 |
_.head(array) |
19 |
_.indexOf(array, value, [fromIndex=0]) |
20 |
_.initial(array) |
21 |
_.intersection([arrays]) |
22 |
_.intersectionBy([arrays], [iteratee=_.identity]) |
23 |
_.intersectionWith([arrays], [comparator]) |
24 |
_.join(array, [separator=”,”]) |
25 |
_.last(array) |
26 |
_.lastIndexOf(array, value, [fromIndex=array.length-1]) |
27 |
_.nth(array, [n=0]) |
28 |
_.pull(array, [values]) |
29 |
_.pullAll(array, values) |
30 |
_.pullAllBy(array, values, [iteratee=_.identity]) |
31 |
_.pullAllWith(array, values, [comparator]) |
32 |
_.pullAt(array, [indexes]) |
33 |
_.remove(array, [predicate=_.identity]) |
34 |
_.reverse(array) |
35 |
_.slice(array, [start=0], [end=array.length]) |
36 |
_.sortedIndex(array, value) |
37 |
_.sortedIndexBy(array, value, [iteratee=_.identity]) |
38 |
_.sortedIndexOf(array, value) |
39 |
_.sortedLastIndex(array, value) |
40 |
_.sortedLastIndexBy(array, value, [iteratee=_.identity]) |
41 |
_.sortedLastIndexOf(array, value) |
42 |
_.sortedUniq(array) |
43 |
_.sortedUniqBy(array, [iteratee]) |
44 |
_.tail(array) |
45 |
_.take(array, [n=1]) |
46 |
_.takeRight(array, [n=1]) |
47 |
_.takeRightWhile(array, [predicate=_.identity]) |
48 |
_.takeWhile(array, [predicate=_.identity]) |
49 |
_.union([arrays]) |
50 |
_.unionBy([arrays], [iteratee=_.identity]) |
51 |
_.unionWith([arrays], [comparator]) |
52 |
_.uniq(array) |
53 |
_.uniqBy(array, [iteratee=_.identity]) |
54 |
_.uniqWith(array, [comparator]) |
55 |
_.unzip(array) |
56 |
_.unzipWith(array, [iteratee=_.identity]) |
57 |
_.without(array, [values]) |
58 |
_.xor([arrays]) |
59 |
_.xorBy([arrays], [iteratee=_.identity]) |
60 |
_.xorWith([arrays], [comparator]) |
61 |
_.zip([arrays]) |
62 |
_.zipObject([props=[]], [values=[]]) |
63 |
_.zipObjectDeep([props=[]], [values=[]]) |
64 |
_.zipWith([arrays], [iteratee=_.identity]) |
”;