The throw statement is used to throw/generate an error. It allows us to create our own custom errors. In other words, we can say that the throw statement throws an exception. It can be String, Number, Boolean, Object, etc.
Its syntax is:- throw expression;
|expression||Required. The exception to throw.|