-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
55 lines (44 loc) · 1.07 KB
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Chop</title>
</head>
<body>
</body>
<script src="chop.js"></script>
<script>
var Human = Chop.extend({ //instance members
name : "John Doe",
constructor : function (name) {
if(name) this.name = name;
Human.incrementCounter();
},
hello : function () {
console.log("Hello i am ", this.name);
}
},{ //class members
counter : 0,
getCounter : function () { return Human.counter; },
incrementCounter : function () { Human.counter+=1; }
});
var Hero = Human.extend({
constructor : function (name, nickName) {
Hero.__super__.constructor.call(this, name);
this.nickName = nickName;
},
hello : function () {
Hero.__super__.hello.call(this);
console.log("My Hero name is", this.nickName);
}
});
var john = new Human();
var bob = new Human("Bob Morane");
john.hello();
bob.hello();
console.log(Human.getCounter(), " Humans");
var clark = new Hero("Clark Kent", "Super Man");
console.log(Human.getCounter(), " Humans");
clark.hello();
</script>
</html>