My own super implementation (getting function object)

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();
    }
    
    getSuperGetValue () {
    	return super.getValue;
    }
}

function log (text) {
	var line = document.createElement("div");
  line.appendChild(document.createTextNode(text));
  document.body.appendChild(line);
}

var b = new B();
var superGetValue = b.getSuperGetValue();
log("superGetValue is a " + typeof superGetValue);
try {
	log("superGetValue() = " + superGetValue());
} catch (e) {
	log("superGetValue() throws " + e.message);
}
log("superGetValue === A.prototype.getValue? " + (superGetValue === A.prototype.getValue));