JavaScript继承和构造函数属性
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); //trueconsole.log(new b() instanceof b); //trueconsole.log(new c() instanceof c); //true
(new c()).constructor
a()
Object.getPrototypeOf(new c())
a{ }
instanceof
new c()
c
?
相关分类