@f/find-index
v1.0.0
Published
Find the index of an item in an array, given a predicate
Downloads
3
Readme
find-index
Find the index of an item in an array, given a predicate
Installation
$ npm install @f/find-indexUsage
var findIndex = require('@f/find-index')
findIndex([1, 2, 3], n => n === 3) === 2API
findIndex(arr, fn, fromIndex)
arr- Array to searchfn- Predicate function that is called on each item. If it returns true, the index of that item is returned fromfindIndex.fromIndex- Optional. Defaults to 0. The starting place in the array to search from.
Returns: The index of the first item that fn returns true for. If no such item is found, returns -1.
License
MIT
