Skip to content
This repository was archived by the owner on Oct 17, 2025. It is now read-only.

Commit 39dc22b

Browse files
Disambiguate super from this inheritance (#2854)
* Disambiguate `super` from `this` inheritance If the child class inherits a function, calling it from `super` behaves identically to calling it from `this`. But by overriding the inherited definition, the example demonstrates that `super` bypasses the child’s definition and goes to the parent’s instead. * explicitly call out local definition being bypassed Co-authored-by: Joshua Chen <[email protected]> --------- Co-authored-by: Joshua Chen <[email protected]>
1 parent 0dfc9ae commit 39dc22b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

live-examples/js-examples/expressions/expressions-super.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ class FooBar extends Foo {
1414
this.index = index;
1515
}
1616

17+
// Does not get called
18+
getNameSeparator() {
19+
return '/';
20+
}
21+
1722
getFullName() {
1823
return this.name + super.getNameSeparator() + this.index;
1924
}

0 commit comments

Comments
 (0)