1

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))
1
  • 1
    You can use [array].indexOf
    – Gabe
    Mar 18, 2015 at 12:55

1 Answer 1

4
  1. Opens documentation

  2. Looks on left

  3. 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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.