dimanche 31 mai 2015

How to create Abstract base class in JavaScript that can't be Instantiated

I have a class

function Node() {
    //implementation
}
and another class

function AttributionalNode() {
    this.prototype.setAttr = function (attr) {
        this.atText = attr;
    };
}

AttributionalNode.prototype = new Node();
AttributionalNode.prototype.constructor = AttributionalNode;

How to make class Node() so it can't be instantiated? e.g when I try

var node = new Node();

So it throws an Exception?

Aucun commentaire:

Enregistrer un commentaire