title: How to get the indexOf an object within an AngularJS response object collection?
body: <h1>Use Case</h1>
  
  <p>I have a collection of objects returned from a REST request. Angular automatically populates each element with a <code>$$hashKey</code>. The problem is that when I search for an object in that array without the <code>$$hashKey</code>, it returns -1. This makes sense. Unfortunately, I don't have knowledge of the value of <code>$$hashKey</code>.</p>
  
  <h2>Question</h2>
  
  <p>Is there a more effective way to search for an object within an object collection returned from a REST request in AngularJS without stripping out the <code>$$hashKey</code> property?</p>
  
  <h2>Code</h2>
  
  <pre><code>function arrayObjectIndexOf(arr, obj) {
  var regex = /,?"\$\$hashKey":".*?",?/;
      var search = JSON.stringify(obj).replace(regex, '');
      console.log(search);
      for ( var i = 0, k = arr.length; i &lt; k; i++ ){
          if (JSON.stringify(arr[i]).replace(regex, '') == search) {
              return i;
          }
      };
      return -1;
  };
  </code></pre>