Skip to content

Instantly share code, notes, and snippets.

@elierotenberg
Created June 21, 2015 17:47
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 elierotenberg/61bc22f8a3eda66a4ffe to your computer and use it in GitHub Desktop.
Save elierotenberg/61bc22f8a3eda66a4ffe to your computer and use it in GitHub Desktop.
super return value
let x;
class A {
constructor() {
this.a = true;
// explictly returns this
return this;
}
}
class B extends A {
constructor() {
x = super();
}
}
new B();
assert(x !== void 0);
let x;
class A {
constructor() {
this.a = true;
// implicitly returns this?
}
}
class B extends A {
constructor() {
x = super();
}
}
new B();
assert(x === void 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment