-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorial22 Prototype.html
More file actions
33 lines (33 loc) · 1.01 KB
/
Tutorial22 Prototype.html
File metadata and controls
33 lines (33 loc) · 1.01 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
<!doctype html>
<html>
<head>
<title>
Tutorial 21 JavaScript -- Create Objects using constructor function.
</title>
<script type="text/javascript">
function myObjectDef(){
this.info = "I am self made info";
this.ShowInfo = function(){
alert(this.info);
}
this.setInfo = function(newInfo){
this.info = newInfo;
}
}
</script>
</head>
<body>
<script type="text/javascript"> // Tag to include JavaScript in HTML.
var obj1 = new myObjectDef();
var obj2 = new myObjectDef();
obj1.setInfo("New Info");
obj1.ShowInfo();
obj2.setInfo("Test New Info");
obj2.ShowInfo();
myObjectDef.prototype.showLatestInfo = function(){
alert("New Method");
}
obj2.showLatestInfo();
</script>
</body>
</html>