KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need basically the same functionality as Underscore's find but with the index of the element as a result (and not the element itself). As far as I know, Underscore's indexOf looks for a value and doesn't take a function. Same problem for jQuery's inArray function. I came up with the following implementation, but I'm not sure it is the most efficient: function myIndexOf(arr, filter) { var index; $.each(arr, function (i, elt) { if (filter(elt)) { index=i; return false; } }); return index; }
Tags (comma-separated)
Save Edits
Cancel