Skip to main content
Module

x/lodash_es/mod.ts>findIndex

lodash for deno use
Latest
function findIndex
import { findIndex } from "https://deno.land/x/lodash_es@v0.0.2/mod.ts";

This method is like _.find except that it returns the index of the first element predicate returns truthy for instead of the element itself.

Examples

var users = [ { 'user': 'barney', 'active': false }, { 'user': 'fred', 'active': false }, { 'user': 'pebbles', 'active': true } ];

_.findIndex(users, function(o) { return o.user == 'barney'; }); // => 0

// The _.matches iteratee shorthand. _.findIndex(users, { 'user': 'fred', 'active': false }); // => 1

// The _.matchesProperty iteratee shorthand. _.findIndex(users, ['active', false]); // => 0

// The _.property iteratee shorthand. _.findIndex(users, 'active'); // => 2

Parameters

array

The array to inspect.

predicate
fromIndex