Skip to content

Instantly share code, notes, and snippets.

@bterlson
Last active September 16, 2015 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bterlson/2e76cfad19c2b46857c0 to your computer and use it in GitHub Desktop.
Save bterlson/2e76cfad19c2b46857c0 to your computer and use it in GitHub Desktop.
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