function Person(name){
this.name = name;
} Person.prototype = {
say: function(){
alert('hi');
},
sayName: function(){
alert(this.name);
}
}; function Programmer(){
this.say = function(){
alert('im Programmer, my name is ' + this.name);
}
} Programmer.prototype = new Person('mikej');
//手动修正构造函数
Programmer.prototype.constructor = Programmer;
var p1 = new Programmer(); console.dir(Programmer.prototype.constructor);//Programmer
console.dir(p1.constructor);//Programmer
console.dir(p1);