参考示例
<script>
function Student(name, gender, score) {
this.name = name;
this.gender = gender;
this.score = score;
this.qulity = 100;
}
Student.prototype.sumScore = function () {
return this.score + this.qulity;
};
var whh = new Student('王花花', '男', 89);
var lsd = new Student('李拴蛋', '女', 40);
console.log(whh.name, whh.sumScore());
console.log(lsd.name, lsd.sumScore());
</script>
登录后评论