原型模式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>原型模式</title>
</head>
<body>
<script>
function Student1(name, gender, score) {
this.name = name;
this.gender = gender;
this.score = score;
this.qulity = 100;
//将方法定义在原型上
Student1.prototype.sumScore = function () {
return this.score + this.qulity;
}
}
var whh = new Student1('王花花', '男', 89)
console.log(whh);
console.log(whh.sumScore());
</script>
</body>
</html>