重新指向了constructor,p2怎么访问不到copy函数?
function Person(name) {
this.name = name;
}
Person.prototype.copy = function() {
return new this.constructor(this.name);
}
var p1 = new Person('李四');
//console.log(Person.prototype);
Person.prototype = {
show: function() {
console.log('show');
}
}
Person.prototype.constructor=Person;
//console.log(Person.prototype);
var p2 = new Person('张三');
莫回无
相关分类