title: Most common way to extend an object
body: <p>Let's say I have the following object to represent a book:</p>
  <pre><code>const book = {
      name: undefined,
      author: {
          surname: undefined
      }
  }
  </code></pre>
  <p>What would be the suggested way to create new instances/objects of the book (aside from using the class approach)? I suppose the ways I've seen it done are as follows:</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>const book = {
      name: undefined,
      author: {
          surname: undefined
      }
  }
  let hamlet1 = Object.assign(book, {name: "Hamlet", author: {surname: "Shakespeare"}});
  let hamlet2 = {...book, name: "Hamlet", author: {surname: "Shakespeare"}}
  let hamlet3 = Object.create(book);
  hamlet3.name = "Hamlet";
  hamlet3.author.surname = "Shakespeare";
  console.log(hamlet1, hamlet2, hamlet3);</code></pre>
  </div>
  </div>
  </p>
  <p>Is there a suggested way to create instances of a typed object? I suppose the equivalent of having a struct in C and then filling its values after declaration.</p>