JS class inheritance woes. i.e. wtf?

Suppose I have two classes. One is a base class extending from MonoBehaviour. We'll call it Base. There's a method in this class called DoStuff(), which is called at various points in Update. I have a second class called Thing that extends from Base. What I'm wondering is, can I override the DoStuff() method in Thing so that when it's called via the base class, the derived method is used?

Example:

class Base extends MonoBehaviour {

function Update()
{
  DoStuff();
}

function DoStuff()
{
  //do some stuff
}

}

and....

class Thing extends Base {

function DoStuff()
{
   //do some different stuff
}

}

Will this ever work? It seems like Thing's DoStuff() is completely ignored. I'm probably missing something.

This will work yes. But you have to cast it to class Thing, otherwise its considered class base and the function of class base will be called.

The redeclaration in the extended class does not make it go away in the base class.

You need to make both versions of DoStuff virtual, which means that when DoStuff is called, it'll look for most specific version of the function

As it is now, they're both completely different functions with the same name, so from Update, DoStuff references the base class's version, not your extending class

e.g.

class Thing extends Base {

    virtual function DoStuff() //if Base has this as virtual too, Update calling DoStuff will call this function
    {
       //do some different stuff
    }

}