【发布时间】:2012-06-01 04:04:42
【问题描述】:
问题:为什么p1的构造函数出来是Person,不应该是Man吗?
function Person()
{
this.type='person'
}
function Man()
{
this.type='Man'
}
Man.prototype=new Person();
var p1=new Man();
console.log('p1\'s constructor is:'+p1.constructor);
console.log('p1 is instance of Man:'+(p1 instanceof Man));
console.log('p1 is instance of Person:'+(p1 instanceof Person));
【问题讨论】:
标签: javascript inheritance prototype