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?

If you do not use new then the object will be destroyed when it goes out of scope.