title: Iterate over JavaScript object with index
body: <p>I am trying to loop over a JavaScript object in ES6.</p>
  
  <pre><code> for (let [value, index] of object) {
      do something with rest
      if (index &gt;= 1) {
         // do something with first item
      }
    }
  </code></pre>
  
  <p>It works fine, although when I try to use index to get the first item it returns an error in console:</p>
  
  <pre><code>Uncaught TypeError: Invalid attempt to destructure non-iterable instance
  </code></pre>
  
  <p>Any ideas on how to loop over an object with index? thanks </p>