-
Notifications
You must be signed in to change notification settings - Fork 78
/
Copy path继承初见.html
36 lines (33 loc) · 921 Bytes
/
继承初见.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>继承初见</title>
</head>
<body>
<script>
window.onload=function(){
function Person(name,age){
this.age=age;
this.name=name;
}
Person.prototype.setName=function(name){
this.name=name
}
function Student(name,age,price){
this.price=price;
Person.call(this,name,age);
}
Student.prototype=new Person();
Student.prototype.constractor=Student;
Student.prototype.setPrice=function(price){
this.price=price;
}
var s=new Student("tom",12,10000);
s.setName("wangzhan")
s.setPrice("19000")
console.log(s.name,s.age,s.price);
}
</script>
</body>
</html>