-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprototype.html
More file actions
38 lines (34 loc) · 1.1 KB
/
prototype.html
File metadata and controls
38 lines (34 loc) · 1.1 KB
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
37
38
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>原型的练习</title>
</head>
<body>
<h1>看看测试效果</h1>
<p id="demo1"></p>
<p id="demo2"></p>
<script type="text/javascript">
function Person(name, age, job) {
this.name = name;
this.age = age;
this.job = job;
this.birth = function () {
return day.getFullYear() - this.age;
};
this.changeName = function (name) {
this.name = name;
}
}
Person.prototype.money = 1500;
var hjb = new Person('黄建波', 22, 'stu');
hjb.habit = 'travel around the world';
var zy = new Person('张屹', 21, 'stu');
zy.changeName('yy');
document.getElementById("demo1").innerHTML = 'hjb\'s information : ' + hjb.birth() + '<br>';
document.getElementById('demo2').innerHTML = zy.name;
</script>
</body>
</html>