问题:
I have seen objects being created this way:我见过以这种方式创建的对象:
const obj = new Foo;
But I thought that the parentheses are not optional when creating an object:但是我认为在创建对象时括号不是可选的:
const obj = new Foo();
Is the former way of creating objects valid and defined in the ECMAScript standard?前一种创建对象的方式是否有效并在 ECMAScript 标准中定义? Are there any differences between the former way of creating objects and the later?前者和后者创建对象的方式有什么区别吗? Is one preferred over the other?一个比另一个更受欢迎吗?
解决方案:
参考一: https://en.stackoom.com/question/CjWf参考二: https://stackoom.com/question/CjWf