When is `new Error()` better than `Error()`? When is `new Error()` better than `Error()`? javascript javascript

When is `new Error()` better than `Error()`?


Is there some reason for this?

It's simply the habit of always calling constructors with new. Consistency rules!

It's a good practice to do even when they work without new, and recommended by several style guides and related tooling. Btw, since ES6 Error is subclassible, and its subclasses will require new.