I need the index of the first value in the array, that matches a custom compare function.
The very nice underscorej has a \"find\" function that returns the
using underscore I came up with something copied from their find implementation using _.any:
findIndex = function (obj, iterator, context) {
var idx;
_.any(obj, function (value, index, list) {
if (iterator.call(context, value, index, list)) {
idx = index;
return true;
}
});
return idx;
};
What do you think - do you have any better solutions?