title: flatten an array of objects in javascript
body: <p>I have a data structure that looks like this</p>
  
  <pre><code>const array = [{
      name: 'bar',
    children: [{
      name: 'foo',
      children: [{
          name: 'baz123',
      }, {
          name: 'baz',
      }]
    }]
  }, {
      name: 'shallowKey'
  }, {
      name: 'abc'
  }];
  </code></pre>
  
  <p>And I would like to flatten it to look something like this</p>
  
  <pre><code>[{
      name: 'bar'
  }, {
      name: 'foo',
  }, {
      name: 'baz123',
  }, {
      name: 'baz',
  }, {
      name: 'shallowKey'
  }, {
      name: 'abc'
  }];
  </code></pre>
  
  <p>I tried lodash like this <a href="https://jsfiddle.net/hmzhjji/081q60qg/1/" rel="nofollow noreferrer">https://jsfiddle.net/hmzhjji/081q60qg/1/</a>
  But it's not doing anything, any other way I can do this?</p>
  
  <p>Thanks</p>