Рассмотрим следующий код.
function a() {}
function b() {}
function c() {}
b.prototype = new a();
c.prototype = new b();
console.log((new a()).constructor); //a()
console.log((new b()).constructor); //a()
console.log((new c()).constructor); //a()
Кроме того, обратите внимание на следующее.
console.log(new a() instanceof a); //true
console.log(new b() instanceof b); //true
console.log(new c() instanceof c); //true
(new c ()). Constructor
равно to a ()
и Object.getPrototypeOf (new c ())
is a {}
, как возможно для instanceof
знайте, что new c ()
является экземпляром c
?