title: Using Object.assign and Object.create for inheritance
body: <p>I typically implement inheritance along the following lines.</p>
  
  <pre><code>function Animal () { this.x = 0; this.y = 0;}
  
  Animal.prototype.locate = function() { 
    console.log(this.x, this.y);
    return this;
  };
  Animal.prototype.move = function(x, y) {
    this.x = this.x + x;
    this.y = this.y + y; 
    return this;
  }
  
  
  function Duck () {
      Animal.call(this);
  }
  
  Duck.prototype = new Animal();
  Duck.prototype.constructor = Duck;
  Duck.prototype.speak = function () {
      console.log("quack");
      return this;
  }
  
  var daffy = new Duck();
  
  daffy.move(6, 7).locate().speak();
  </code></pre>
  
  <p>I've read <a href="https://medium.com/javascript-scene/common-misconceptions-about-inheritance-in-javascript-d5d9bab29b0a" rel="noreferrer">this post by Eric Elliott</a> and if I understand correctly I can use <code>Object.create</code> and <code>Object.assign</code> instead? Is it really that simple? </p>
  
  <pre><code>var animal = {
     x : 0,
     y : 0,
     locate : function () { 
       console.log(this.x, this.y);
       return this;
     },
     move : function (x, y) { 
       this.x = this.x + x; 
       this.y = this.y + y;
       return this;
     }
  }
  
  var duck = function () {
     return Object.assign(Object.create(animal), {
       speak : function () { 
         console.log("quack");
         return this;
       }
     });
  }
  
  var daffy = duck();
  
  daffy.move(6, 7).locate().speak();
  </code></pre>
  
  <p>As an aside, by convention constructor functions are capitalized, should object literals that act as constructors also be capitalized?</p>
  
  <p>I realise there are many questions here discussing <code>new</code> versus <code>Object.create</code>, but they typically seem to relate to <code>Duck.prototype = new Animal();</code> versus <code>Duck.prototype = Object.create(Animal.prototype);</code></p>