To do this, define a new class that inherits exception, add all four exception constructors, and optionally an additional constructor that takes an innerexception as well as additional information, and throw รขโฌยฆ The new keyword in javascript can be quite confusing when it is first encountered, as people tend to think that javascript is not an object-oriented programming language. What is it? You should use new when you wish an object to remain in existence until you delete it.
Understanding the Context
If you do not use new then the object will be destroyed when it goes out of scope.