Skip to content

Instantly share code, notes, and snippets.

@getify
Created August 25, 2016 21:47
Show Gist options
  • Select an option

  • Save getify/48967903380cf6bd319605ef1e4c3d35 to your computer and use it in GitHub Desktop.

Select an option

Save getify/48967903380cf6bd319605ef1e4c3d35 to your computer and use it in GitHub Desktop.
`super` being static rather than dynamic
class P {
foo() { console.log( "P.foo" ); }
}
class C extends P {
foo() {
super();
}
}
var c1 = new C();
c1.foo(); // "P.foo"
var D = {
foo: function() { console.log( "D.foo" ); }
};
var E = {
foo: C.prototype.foo
};
// Link E to D for delegation
Object.setPrototypeOf( E, D );
E.foo(); // "P.foo" <-- not D.foo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment