Skip to content

Instantly share code, notes, and snippets.

@cspotcode
Created May 16, 2013 19:32
Show Gist options
  • Save cspotcode/5594389 to your computer and use it in GitHub Desktop.
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
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