Loading ...
Sorry, an error occurred while loading the content.

new RegExp/new Error

Expand Messages
  • Stoyan Stefanov
    Hi folks, I was wondering - should JSLint tolerate the use of the constructors Error, EvalError... etc. and RegExp when invoked without `new`. new
    Message 1 of 1 , Mar 29 12:10 AM
    • 0 Attachment
      Hi folks,

      I was wondering - should JSLint tolerate the use of the constructors Error,
      EvalError... etc. and RegExp when invoked without `new`.

      new RegExp(pattern)
      is the same as
      RegExp(pattern)

      Also
      throw new Error(Œouch!¹)
      and
      throw Error(Œouch!¹)
      work the same.

      Will making an exception for those constructors cause inconsistency that is
      worse than the few extra `new` operators that can otherwise be removed?

      Best,
      Stoyan


      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.