I noticed that every tutorial on how to do JavaScript inheritance does this:
SubClass.prototype = new SuperClass();
But this will create a single instance of the super class and share it among all the instances of the sub class.
The problem is that I would like to pass arguments to the super class constructor which originate from arguments passed to the sub class.
In Java this would be done like this:
class SubClass extends SuperClass {
public SubClass(String s) {
super(s);
}
}
I tried doing something like this:
function SubClass(args) {
this.constructor.prototype = new SuperClass(args);
}
But this will not work. So is there a way to do this in JavaScript?