title: Is it possible to destructure a nested object without knowing the key of the parent?
body: <p>I was wondering if it is possible to destructure a nested object without knowing the key of the parent object?</p>
  
  <p>The reason to do this is that mongoose validation errors returns an object in the <code>errors</code> key and each entry of this object is another object where the key is the name of the field that has an error.</p>
  
  <pre><code>const data = {
    name: {
      path: 'name',
      name: 'The error message'
    },
    email: {
      path: 'email',
      name: 'Another error message'
    }
  }
  </code></pre>
  
  <p>So the result can be something like</p>
  
  <pre><code>{
    name: 'The error message',
    email: 'Another error message'
  }
  </code></pre>
  
  <p>Is it possible that the unique way to do this is using <code>for in</code> loop and perform the destructuring assignment inside of it?</p>
  
  <pre><code>let message = {}
  for (var k in data) {
    var { path, name } = data[k]
    message[path] = name
  }
  </code></pre>