Reputation: 723
Is there a simple way to get key from value?
var arr = [1,2,3,4,10];
if(_.contains(arr, 3))
alert(KEY of 3 (2))
Upvotes: 1
Views: 1137
Reputation: 1074218
Opens documentation
Looks on left
Finds _.indexOf
:
_.indexOf(array, value, [isSorted])
Returns the index at which value can be found in the array, or -1 if value is not present in the array.
Upvotes: 4