Calling a grandparent method but skipping the parent
Stack overflow question, I bet using a mixin with implements makes more sense, but this is interesting nevertheless.
JavaScript
var GrandParent = new Class({
initialize: function(){
console.log('init:GrandParent');
},
talk: function(){
console.log('talk:GrandParent');
}
});
var Parent = new Class({
Extends: GrandParent,
initialize: function(){
this.parent();
console.log('init:Parent');
},
talk: function(){
console.log('talk:Parent');
}
});
var Child = new Class({
Extends: Parent,
initialize: function(){
this.parent();
console.log('init:Child');
},
talk: function(){
// instead of this.parent()
GrandParent.prototype.talk.apply(this);
console.log('talk:Child');
}
});
var kid = new Child;
kid.talk();