You can call the Base constructor first:
function MyClass() { BaseClass.call(this); this.talk = function() { alert("I'm MyClass"); } }
otherwise BaseClass.talk
overwrite MyClass.talk
.
As a side note, using the concept of βclassesβ in javascript is quite counterproductive because it is not how this language works. JS uses prototype inheritance, that is, you retrieve new objects from other objects, not from "classes". In addition, each function in JS is βvirtualβ in the sense of C ++, because its this
pointer depends on how the function is called, and not on where it is defined.
source share