<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
function Student(){
this.a = "举世无双";
this.b = "一骑当千";
this.c = "万夫莫敌";
this.d = "所向披靡"
this.laugh = function(){
document.getElementById("p1").innerHTML = "笑他";
}
this.eat = function(){
alert("少吃点吧,该减肥了");
}
function song(){
alert("一展歌喉")
}
song();
}
var stu = new Student();
Student.prototype.goSchool = function(){
alert("去上学");
}
var stu2 = new Student();
function YYY(){
this.y = "我是小y";
}
Student.prototype = new YYY();
var stu3 = new Student;
</script>
</head>
<body>
<input type="button" value="a" onclick="alert(stu.a)">
<input type="button" value="b" onclick="alert(stu.b)">
<input type="button" value="c" onclick="alert(stu.c)">
<input type="button" value="d" onclick="alert(stu.d)">
<input type="button" value="laugh" onclick="stu.laugh()">
<input type="button" value="eat" onclick="stu.eat()">
<input type="button" value="song" onclick="Student">
<input type="button" value="扩展去上学" onclick="stu2.goSchool()">
<input type="button" value="继承" onclick="alert(stu3.y)">
<p id="p1"></p>
</body>
</html>