> Why does calling a class throw an exception instead of just creating a
new instance
backward compatibility and early "rushed" behavior is one of the reasons.
`String() instanceof String` is false and it's just one example.
Because of primitives and `typeof`, `new Symbol` throws too, you are not
meant to do that.
Array and Regexp though, have no primitive namespace, but that's old gotcha
later specs tried to prevent.
What about `new Date` ? Now that's an instance, while `Date()` is a string.
Using `new` makes your intent unambiguous in a PL where functions can be
used as constructors too.
There is also the possibility to create functions that cannot be used as
`new`:
```js
const method = {method(){}}.method;
new method; // throws
```
Accordingly, since you have Reflect for all procedural use cases, what is
the benefit of not using `new` where it's an instance of that Class you are
after?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss