标签: javascript ecmascript-6
是否可以在静态方法中使用ES6创建一个新的self / this实例?例如;
class myClass { static model() { return new this; } }
此类情景是否有公认的模式?
非常感谢。
答案 0 :(得分:4)
是的,这正是你要做的。
如果您不希望子类使用子类构造函数,请明确引用您的类,类似于accessing other static methods。