title: Why is destructuring an array in javascript slower than for an object?
body: <p>I have ran a few different variations of this, but this is the basic test that I have made on jsbench.me:</p>
  <p><a href="https://jsbench.me/j2klgojvih/1" rel="nofollow noreferrer">https://jsbench.me/j2klgojvih/1</a></p>
  <p>This initial benchmark has an obvious initial optimization that makes the object destructure significantly faster. If you move the declaration of t into each test block, that underlying optimization disappears, but the array destructure still loses.</p>
  <p>The test is a simple concept represented by:</p>
  <pre><code>const t = [1, 2, 3];
  
  // Test 1 (Slower)
  const [x, y, z] = t;
  
  // Test 2 (Faster)
  const {0: x, 1: y, 2: z} = t;
  </code></pre>
  <p>I would think V8 (or any JS engine) could/should run the array destructuring faster; however, I have not been able to make a variation of the test where that is the case.</p>
  <p>If I were to poke a guess at the reasoning, it'd be that array destructuring runs some iterator to loop through the array.</p>