new this(...args)什么意思啊?

下面代码什么意思啊


class  A{

  static instance(...args) {

        this.i = this.i || new this(...args)

        return this.i

    }

}

this.i = this.i || new this(...args)完全看不懂啊,这里this.i是个什么鬼

new this(...args)又是什么?


绝地无双
浏览 768回答 1
1回答

繁星coding

短路。等同於:class A{  static instance(...args) {        if (this.i) this.i = this.i;        else this.i = new this(...args);        return this.i;    }}new this(...args) is equal to new A(...args).
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript