1.语法错误
try {
var error = 'error';// 大写分号
} catch(e) {
console.log('我感知不到错误');
console.log(e);
}
错误提示:
![](https://img.haomeiwen.com/i1489163/44134d2a2d33c7cb.png)
注:
一般语法错误在编辑器就会体现出来,常表现的错误信息为: Uncaught SyntaxError: Invalid or unexpected token xxx 这样。但是这种错误会直接抛出异常,常使程序崩溃,一般在编码时候容易观察得到。
try {
var error = 'error';// 大写分号
} catch(e) {
console.log('我感知不到错误');
console.log(e);
}
一般语法错误在编辑器就会体现出来,常表现的错误信息为: Uncaught SyntaxError: Invalid or unexpected token xxx 这样。但是这种错误会直接抛出异常,常使程序崩溃,一般在编码时候容易观察得到。
本文标题:js常见的错误提示
本文链接:https://www.haomeiwen.com/subject/ojnbhftx.html
网友评论