Last active
September 16, 2015 17:11
-
-
Save bterlson/2e76cfad19c2b46857c0 to your computer and use it in GitHub Desktop.
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 A { } | |
class B extends A { | |
method() { super.x = 1; return super.x; } | |
} | |
var b = new B(); | |
b.method(); // undefined (no property x on A.prototype or above) | |
b.hasOwnProperty('x'); // true (own property created on receiver by [[set]]) | |
class C extends B { | |
get x() { return "gotten" } | |
} | |
var c = new C(); | |
c.x; // "gotten" (getter invoked) | |
c.method(); // undefined (no setter invoked or error thrown) | |
c.x; // 1 (property now shadows getter on C.prototype) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment