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

Sign up to request clarification or add additional context in comments.

1 Comment

Oh sorry! Of coz it is. Thnx!

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.