js- throw

2023-03-07,

// Create an object type UserException
function UserException (message){
this.message=message;
this.name="UserException";
}

// Make the exception convert to a pretty string when used as
// a string (e.g. by the error console)
UserException.prototype.toString = function (){
return this.name + ': "' + this.message + '"';
}//这怎么有点不懂呢,这是完成了什么功能?

将这段注销,区别在于抛出错误是否已一个结构体抛出(‘{}’),有没有人能解释一下

// Create an instance of the object type and throw it
throw new UserException("Value too high");

js- throw的相关教程结束。

《js- throw.doc》

下载本文的Word格式文档,以方便收藏与打印。