title: Nested object in array - object destructing es6
body: <p>So I know you can do object destructing like: <code>const { item } = data;</code></p>
  
  <p>Also array destructing like: <code>const [ item ] = data;</code></p>
  
  <p>You can also do this in function params like: <code>const x = ({ item }) =&gt; item;</code></p>
  
  <p>And I've seen lots of questions and answers on it. However I haven't seen an example and a good explanation of nested objects in an array.</p>
  
  <hr>
  
  <pre><code>const test = [{ count: 1 }];
  
  const [{ count }] = test;
  </code></pre>
  
  <p>I'd normally do:</p>
  
  <pre><code>const x = test[0];
  
  const { count } = x;
  </code></pre>
  
  <p>It was only today while testing in codepen that I figured out you could destructor them both within the same assignment.</p>
  
  <p>Could anyone explain what's going on when I'm doing <code>[{ count }]</code>? Because I'm doing array destructing with the <code>const [] = test</code> but I'm not destructing anything so that obviously fails. If I then <code>{ count }</code> within that I get the value out I want.</p>
  
  <p>I can't break it down enough to understand how it's working. I'd assume <code>[] = test</code> is the same as <code>test[0]</code> then i do <code>{ count } = test[0]</code>. But I'd just like to understand how it's working more.</p>
  
  <p><em>I did have a look through some of the MDN docs and stuff but I can't find a good explanation on the above scenario I mentioned.</em></p>
  
  <p>Thanks!</p>