Ultimamente ho letto molto su alcuni concetti chiave di JS e l'ereditarietà è un po 'confusa.
Ecco i metodi che conosco:
// Base class
function Parent(foo) {
  if (foo === undefined) {
    throw new TypeError('foo is undefined');
  }
  this.foo = foo;
}
// Derived class
function Child(foo, bar) {
  if (foo === undefined) {
    throw new TypeError('foo is undefined');
  }
  if (bar === undefined) {
    throw new TypeError('bar is undefined');
  }
  Parent.call(this, foo);
  this.bar = bar;
}
1. Utilizzo di una funzione temporanea
function tmpFn(){}
tmpFn.prototype = Parent.prototype;
Child.prototype = new tmpFn();
Child.prototype.constructor = Child;
 2. Utilizzo di un'istanza   Parent    
Child.prototype = new Parent();       // fail
Child.prototype = new Parent(null);   // hax
Child.prototype.constructor = Child;
 3. Utilizzando   Object#create   
Child.prototype = Object.create(Parent.prototype);
Child.prototype.constructor = Child;
Dopo aver esaminato le catene di prototipi per tutti i metodi, mi sono reso conto che tutti producono lo stesso risultato (che è abbastanza ovvio). Ma in tutti questi metodi, c'è una cosa che è comune. Stiamo creando un terzo oggetto per sostituire il prototipo e quindi reimpostare il costruttore. ci sono due override coinvolti: -
-    Child.prototype = ...
-    Child.prototype.constructor = Child
 Questo mi ha fatto pensare: perché non fare semplicemente   Child.prototype.__proto__ = Parent.prototype   ?
O un'alternativa  più sicura ,   Object.setPrototypeOf(Child.prototype, Parent.prototype)   . 
Qual è il danno in questo?