-
-
Save getify/48967903380cf6bd319605ef1e4c3d35 to your computer and use it in GitHub Desktop.
`super` being static rather than dynamic
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
| 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