title: Javascript Object destructuring and default parameters combined
body: <p>Today I came across the following syntax which I didn't recognize:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="true">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const createUser = ({
    age = 1,
    name = 'Anonymous',
  }) =&gt; ({
    age,
    name,
  });
  
  
  const defaultP = createUser({
    age: 5
  });
  console.log(defaultP);</code></pre>
  </div>
  </div>
  </p>
  
  <p>I think it uses Object destructuring and default parameters in order to set defaults of the object which is send as an argument.</p>
  
  <p>The syntax threw me a bit off because normally I see object destructuring only in the following manner:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let obj = {
     prop1: 1
  }
  
  const {prop1} = obj;
  
  console.log(prop1);</code></pre>
  </div>
  </div>
  </p>
  
  <h2>Question:</h2>
  
  <p>How does this syntax work exactly?</p>