JavaScript的原型对象
程序员文章站
2022-07-07 11:33:04
javascript的原型对象
function person(name,age) {
this.name = name;
this.age = age;
}
person.prototype.sh...
javascript的原型对象
function person(name,age) {
this.name = name;
this.age = age;
}
person.prototype.show = function () {
console.log(this.name);
};
var p1 = new person('xm',18);
var p2 = new person('xh',17);
console.log(p1.show == p2.show); // true