title: JQuery for each function get array index
body: <p>I have an array as follows:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>result = [];
      result.push({label: 'test label 1', value: 'test value 1'});
      result.push({label: 'test label 2', value: 'test value 2'});
  
      $.each(result, function( key, value ) {
          console.log(key);
          console.log(value.label);
      })</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I'm trying to retrieve the index value of the item in the array using 'console.log(key)' but it always returns 0. How do i get the index value of each item in array as it iterates?</p>