-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTutorial21 Objects2.html
More file actions
29 lines (29 loc) · 888 Bytes
/
Tutorial21 Objects2.html
File metadata and controls
29 lines (29 loc) · 888 Bytes
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
<!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();
</script>
</body>
</html>