Skip to content

Instantly share code, notes, and snippets.

@serafo27
Created June 7, 2016 09:54
Show Gist options
  • Save serafo27/8ff908afb19c0dce3ad39636ba29e6c3 to your computer and use it in GitHub Desktop.
Save serafo27/8ff908afb19c0dce3ad39636ba29e6c3 to your computer and use it in GitHub Desktop.
example of abstract, not instantiable, class in javascript
var AbstractClass = (function(){
function AbstractClass() {
if (this.constructor === AbstractClass) {
throw new Error("Can't instantiate abstract class!");
}
};
AbstractClass.prototype.method1 = function() {
throw new Error("Abstract method!");
};
return AbstractClass;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment