_.findIndex

findIndex_.findIndex(array, predicate, [context])
Similar to _.indexOf, returns the first index where the predicate truth test passes; otherwise returns -1.

1
2
3
4
_.findIndex([4, 6, 8, 12], isPrime);
=> -1 // not found
_.findIndex([4, 6, 7, 12], isPrime);
=> 2
doc_Underscore
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.