My own super implementation (redefining parent method)
by Arnaud Buchholz
JavaScript
class A {
constructor (value) {
this._a = true;
if (undefined !== value) {
this._value = value;
}
}
getValue () {
return this._value;
}
}
class B extends A {
constructor () {
super("b");
this._b = true;
}
getValue () {
return super.getValue().toUpperCase();
}
}
function log (text) {
var line = document.createElement("div");
line.appendChild(document.createTextNode(text));
document.body.appendChild(line);
}
var b = new B();
log("b.getValue() = " + b.getValue());
A.prototype.getValue = function () { return "Hello World!"; }
log("After redefining A.prototype.getValue, b.getValue() = " + b.getValue());