Created
June 7, 2016 09:54
-
-
Save serafo27/8ff908afb19c0dce3ad39636ba29e6c3 to your computer and use it in GitHub Desktop.
example of abstract, not instantiable, class in javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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