1

I've seen examples of throw that use Error and new Error:

throw new Error('new Error')

and

throw Error('Error')

i.e.: (function(){ throw new Error('new Error') })() (function(){ throw Error('Error') })() (cut/paste in console to see that they both work)

Is there any reason to include the new?

I ask because I think throwing Errors is preferred to throwing strings .. better stack trace I think, but if the new isn't needed, I'll drop it.

backspaces
  • 3,802
  • 6
  • 34
  • 58
  • [What is the difference between \`throw new Error\` and \`throw someObject\` in JavaScript?](//stackoverflow.com/q/9156176) – Tushar Dec 08 '16 at 04:18
  • Yup it's a dup, thanks! Use the link at the top of the question, not the one directly above. – backspaces Dec 08 '16 at 16:38

0 Answers0