How do I write this C# snipet in java script?

I wrote a script in js, called MyNewJS. MyNewJS sends a message as follows: this.SendMessage(“WhenPlayerDoesThis”).

I’m writing a separate js called MyMessageHandler and it will inherit from MyNewJS and will need to do something whenever the “WheneverPlayerDoesThis” message is sent from MyNewJS.

I have the following C# for MyMessageHandler.cs but need it in java script…someone please help.

   public class MyMessageHandler : MyNewJS
    void WhenPlayerDoesThis() {
    //Do Stuff here

I figured out that the MyMessageHandler inherits from MyNewJS line is translated to:
public class MyMessageHandler extends MyNewJS (in JS), but I can’t find answers for translating the message retrieval after that…

function WhenPlayerDoesThis() {}