Add findLastIndex, update findLast
This commit is contained in:
@ -5,7 +5,7 @@ Returns the last element for which the provided function returns a truthy value.
|
|||||||
Use `Array.filter()` to remove elements for which `fn` returns falsey values, `Array.slice(-1)` to get the last one.
|
Use `Array.filter()` to remove elements for which `fn` returns falsey values, `Array.slice(-1)` to get the last one.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const findLast = (arr, fn) => arr.filter(fn).slice(-1);
|
const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0];
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|||||||
@ -53,6 +53,7 @@ fibonacci:math,array
|
|||||||
filterNonUnique:array
|
filterNonUnique:array
|
||||||
findKey:object,function
|
findKey:object,function
|
||||||
findLast:array
|
findLast:array
|
||||||
|
findLastIndex:array,function
|
||||||
findLastKey:object,function
|
findLastKey:object,function
|
||||||
flatten:array
|
flatten:array
|
||||||
flip:adapter,function
|
flip:adapter,function
|
||||||
|
|||||||
Reference in New Issue
Block a user