-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwith_node.js
More file actions
40 lines (33 loc) · 907 Bytes
/
with_node.js
File metadata and controls
40 lines (33 loc) · 907 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
30
31
32
33
34
35
36
37
38
39
40
var Chop = require('./chop');
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();