Can we omit parentheses when creating an object using the “new” operator?

前端 未结 6 2216
清酒与你
清酒与你 2020-11-22 00:41

I have seen objects being created this way:

const obj = new Foo;

But I thought that the parentheses are not optional when creating an objec

6条回答
  •  生来不讨喜
    2020-11-22 01:05

    If you do not have arguments to pass, the parentheses are optional. Omitting them is just syntactic sugar.

提交回复
热议问题