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? Are there any differences between the former way of creating objects and the later? Is one preferred over the other?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…