Created
May 16, 2013 19:32
-
-
Save cspotcode/5594389 to your computer and use it in GitHub Desktop.
How to do Object.create in JS engines that don't support it
This file contains hidden or 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
SuperClass = function() {} | |
SubClass = function() {} | |
SubClass.prototype = Object.create(SuperClass.prototype); | |
// Or, if the JS engine doesn't have Object.create... | |
var ctor = function() {} | |
ctor.prototype = SuperClass.prototype; | |
SubClass.prototype = new ctor(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment