1.SyntaxError(语法错误) 对象代表尝试解析语法上不合法的代码的错误。
当Javascript语言解析代码时,Javascript引擎发现了不符合语法规范的tokens或token顺序时抛出SyntaxError.
new SyntaxError([message[, fileName[, lineNumber]]])
2.ReferenceError(引用错误) 对象代表当一个不存在的变量被引用时发生的错误。
new ReferenceError([message[, fileName[, lineNumber]]])
messaage:可选。描述可读的错误信息
fileName:可选。包含引起异常代码的文件名
lineNumber:可选。引起异常的代码行号
3.TypeError(类型错误) 对象用来表示值的类型非预期类型时发生的错误。
4.URIError 对象用来表示以一种错误的方式使用全局URI处理函数而产生的错误。
当向全局 URI 处理函数传递一个不合法的URI时,URIError 错误会被抛出。
try {
decodeURIComponent('%');
} catch (e) {
console.log(e instanceof URIError); // true
console.log(e.message); // "malformed URI sequence"
console.log(e.name); // "URIError"
console.log(e.fileName); // "Scratchpad/1"
console.log(e.lineNumber); // 2
console.log(e.columnNumber); // 2
console.log(e.stack); // "@Scratchpad/2:2:3\n"
}
5.RangeError对象标明一个错误,当一个值不在其所允许的范围或者集合中。
new RangeError([message[, fileName[, lineNumber]]])
6.InternalError 对象表示出现在JavaScript引擎内部的错误。 例如: "InternalError: too much recursion"(内部错误:递归过深)。
示例场景通常为某些成分过大,例如:
"too many switch cases"(过多case子句);
"too many parentheses in regular expression"(正则表达式中括号过多);
"array initializer too large"(数组初始化器过大);
"too much recursion"(递归过深)。
7.# EvalError
本对象代表了一个关于 eval 函数的错误.此异常不再会被JavaScript抛出,但是EvalError对象仍然保持兼容性.