Can we alias something non existent in the subclass?

I noticed that some subclasses do not have functions that were inherited from the parent class.

Scene_Menu for example, does not have an update, but Scene_MenuBase does. Can I create something like:

var alias_scene_menu_update = Scene_Menu.prototype.update;Scene_Menu.prototype.update = function() { alias_scene_menu_update.call(this);}even if Scene_Menu.prototype.update never existent since its a subclass of Scene_MenuBase?
Instead of aliasing it, you create the method and call the parent:

Code:
Scene_Menu.prototype.update = function() {  Scene_MenuBase.prototype.update.call(this);}
Thanks! Is this similar to super in RMVXAce?
Not exactly. In JS, we are creating a new method and then calling the old one.

In ruby, the two methods are technically the same.
make sure the parent of the class your sub classing doesn't have said method. because if you do:

parent (has method) -> child (doesn't have method) -> grand child (create method) you are over riding the parent method.
Not exactly. In JS, we are creating a new method and then calling the old one.

In ruby, the two methods are technically the same.
I see, I thought it was the same, thanks for the info.

make sure the parent of the class your sub classing doesn't have said method. because if you do:

parent (has method) -> child (doesn't have method) -> grand child (create method) you are over riding the parent method.
Thanks. I think I need to read more of this before continuing what I was coding, its a big help. 🙂
I noticed that some subclasses do not have functions that were inherited from the parent class.

Scene_Menu for example, does not have an update, but Scene_MenuBase does. Can I create something like:

var alias_scene_menu_update = Scene_Menu.prototype.update;Scene_Menu.prototype.update = function() { alias_scene_menu_update.call(this);}even if Scene_Menu.prototype.update never existent since its a subclass of Scene_MenuBase?
This should work.

Scene_Menu.prototype.update would check its own definitions, and if it can't find it, it'll go up to its parent.

You can verify this in the console:

> Scene_Menu.prototype.updatefunction () { this.updateFade(); this.updateChildren(); AudioManager.checkErrors();}> Scene_MenuBase.prototype.updatefunction () { this.updateFade(); this.updateChildren(); AudioManager.checkErrors();}
make sure the parent of the class your sub classing doesn't have said method. because if you do:

parent (has method) -> child (doesn't have method) -> grand child (create method) you are over riding the parent method.
Wouldn't child also have the method by inheritance?
Wouldn't child also have the method by inheritance?
yes. How ever most people when they alias a method or look for a method on a class, they might not see that "hey this class extends another class." Its rare, but it does happen.

Original thread: https://forums.rpgmakerweb.com/threads/can-we-alias-something-non-existent-in-the-subclass.50325/