-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
31 lines (26 loc) · 897 Bytes
/
example.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
<script type="text/javascript" src="mojo.js"></script>
<script type="text/javascript">
var Person = mojoClass(function(name) {
this.name = name;
}, {
greet: function(someoneElse) {
if(someoneElse) {
return 'Hello, ' + someoneElse + '. My name is ' + this.name + '!';
} else {
return 'Hello. My name is ' + this.name + '!';
}
}
});
var AngryPerson = mojoClass(Person, {
greet: function(someoneElse) {
return this._super.greet(someoneElse).toUpperCase();
}
});
var mark = new Person('Mark');
console.log('Person:', mark.greet());
console.log('Person:', mark.greet('Nathalie'));
var angryMark = new AngryPerson('Mark');
console.log('AngryPerson:', angryMark.greet());
console.log('AngryPerson:', angryMark.greet('Nathalie'));
console.log('AngryPerson instanceof Person?', angryMark instanceof Person);
</script>