作者:从妖妖 | 来源:互联网 | 2023-10-11 11:46
重新指向了constructor,p2怎么访问不到copy函数?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| 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('张三'); |