All these years I've been using "new Error" for nothing


All these years I've been using "new Error" for nothing!?

Just learned that these are equivalent in JS:

throw Error('oops')
and
throw new Error('oops')

Error() can be called with or without new. Both create a new Error instance.

View original on X