示例参考
function User(name, age) {
this.name = name;
this.age = age;
}
User.prototype.greet = function () {
console.log('Yo, 我叫' + this.name
+ ',我今年' + this.age + '岁了');
}
var whh = new User('王花花', 19);
var lsd = new User('李拴蛋', 20);
var zks = new User('赵可爽', 18);
whh.greet()
lsd.greet()
zks.greet()
登录后评论