I'm using prototype's standalone class inheritance: https://github.com/Jakobo/PTClass
And I have the following classes:
App.hello = Class.create({
initialize: function(args) {
this.name = args.name
},
sayHello: function() {
console.log('Hello, ' + this.name);
},
sayGoodbye: function() {
console.log('Goodbye, ' + this.name);
}
});
App.yo = Class.create(App.hello, {
initialize: function($super) {
$super();
},
sayHello: function() {
console.log('Yo, ' + this.name);
}
});
Where the idea is that yo
would inherit from hello
and override its sayHello
method. But also be able to call the sayGoodbye
method in its parent class.
So I call them like so:
var test = new App.hello({name: 'Cameron'});
test.sayHello();
test.sayGoodbye();
var test2 = new App.yo({name: 'Cameron'});
test2.sayHello();
test2.sayGoodbye();
However I get the error that Uncaught TypeError: Cannot read property 'name' of undefined
for my yo
class.
How do I properly inherit from my hello
class?