_.findIndex

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

_.findIndex([4, 6, 8, 12], isPrime);
=> -1 // not found
_.findIndex([4, 6, 7, 12], isPrime);
=> 2
doc_Underscore
2016-04-09 09:05:22
Comments
Leave a Comment

Please login to continue.