title: How to create nested child objects in JavaScript from array?
body: <p>This is the given array:</p>
  
  <pre><code>[{
    key: 1,
    nodes: {}
  }, {
    key: 2,
    nodes: {}
  }, {
    key: 3,
    nodes: {}
  }]
  </code></pre>
  
  <p>How to create nested child objects in JavaScript from this array?</p>
  
  <pre><code>[{
    key: 1,
    nodes: [{
      key: 2,
      nodes: [{
        key: 3,
        nodes: []
      }]
    }]
  }];
  </code></pre>