Should I use new Type() or just Type() for calling a constructor

后端 未结 3 1670
天命终不由人
天命终不由人 2021-01-04 04:32

Both syntaxes are equivalent (at least I suppose they are).

let o1 = new Object()

or

let o2 = Object()

Wh

3条回答
  •  梦谈多话
    2021-01-04 05:23

    They are the same.

    I prefer using 'new', with little good reason other than it is what I am accustomed to in other languages, and it makes it easier to findstr/grep for constructor calls (lacking smart tools to 'find all references' in a solution).

提交回复
热议问题