Skip to content

Instantly share code, notes, and snippets.

@psema4
Created April 11, 2013 18:17
Show Gist options
  • Save psema4/5365829 to your computer and use it in GitHub Desktop.
Save psema4/5365829 to your computer and use it in GitHub Desktop.
ES6 Classes Polyfill (via public-webapps, A Wirfs-Brock)
// ES6
class Sub extends Super {
constructor() {/*constructor body */ }
method1 () {}
static method2 {}
}
// ES3/5
function Sub() {/*constructor body */ }
Sub.__proto__ = Super;
Sub.prototype = Object.create(Super.prototype);
Sub.prototype.method1 = function method1() {};
Sub.method2 = function method2 () {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment