<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script>
var student = new Object();
student.name = "Luna";
student.doHomework=function(){
console.log(this.name+"在写作业");
}
student.doHomework();
student.name = "houzi";
student.doHomework();
var stuent = {
name:"tim",
age:18,
doHomework:function(){
console.log(this.name+"在写作业");
},
eat:function(){
console.log(this.name+"在吃饭");
}
}
function Student(name){
this.name = name;
this.doHomework=function(){
console.log(this.name+"学习");
};
}
var student = new Student("luban");
student.doHomework();
function Stu(){
}
Stu.prototype.name="houyi";
Stu.prototype.doHome=function(){
console.log(this.name+"学习");
};
var stu = new Stu();
stu.doHome();
function Stud(name){
this.name = name;
}
Stud.prototype.doHome=function(){
console.log(this.name+"学习");
};
var stud = new Stud("dashi");
stud.doHome();
</script>
</head>
<body>
</body>
</html>