Created
December 19, 2014 21:58
-
-
Save jacobstr/fbca6104b5e83f22fe50 to your computer and use it in GitHub Desktop.
ES6 Static Factory Magic - How does it work?
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 Parent { | |
| static build() { | |
| return new this(); | |
| } | |
| } | |
| class Child extends Parent { | |
| } | |
| assert(Child.build() instanceof Child); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Well that was a derp - copying and pasting an earlier test led to me calling:
Instead of