What type of exception should be used in JavaScript?

What type of object should be thrown in JavaScript?

I see many examples that throw a plain old stringand seem to be a semi-standard Error. Should I give preference to another?

+5
source share
1 answer

Object Errorand specific error objects, such as TypeError, are fully standardized in the ECMAScript specification. However, in most browsers there are non-standard properties of these objects.

, , , , , Error:

  • , , , message, ;
  • Error Mozilla , fileName, lineNumber stack. Error, .
+6

All Articles