title: AngularJs - check if value exists in array object
body: <pre><code>var SelectedOptionId = 957;
  
  $scope.array = [{"957":"1269"},{"958":"1265"},{"956":"1259"},{"957":"1269"},{"947":"1267"}]
  </code></pre>
  
  <p>Is there a way of checking if a value exists in an that kind of array objects. I am using Angular and underscore.</p>
  
  <p>I have tried all this -</p>
  
  <pre><code>if ($scope.array.indexOf(SelectedOptionId) === -1) {console.log('already exists')}
  </code></pre>
  
  <p>and </p>
  
  <pre><code>console.log($scope.array.hasOwnProperty(SelectedOptionId)); //returns false
  </code></pre>
  
  <p>and</p>
  
  <pre><code>console.log(_.has($scope.array, SelectedOptionId)); //returns false 
  </code></pre>