JavaScript 教程 之基礎教程
阿新 • • 發佈:2018-09-07
ext 分析 java .html doc tac body cli doctype
View Code
1.js 錯誤
var objClass = { foo:1, bar:2 }; function printf() { var aaa:objClass; aaa.foo = 2; console.log(objClass.bar); } function throwIt() { throw new Error(""); } function catchIt() { console.log(catchIt.name); try { throwIt(); }catch(e) { console.log(e.stack); } }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>DataType</title> <script type="text/javascript" src="scripts/dataType.js"></script> </head> <body> <p onclick="catchIt();return false;">Test</p> </body> </html>
明明定義了方法,卻報錯誤,多次嘗試後,分析為js裏面有錯誤,導致編譯其實是不過的,所以加載js是有問題的。
catchIt Error at throwIt (http://localhost:63343/H51/scripts/dataType.js:7:11) at catchIt (http://localhost:63343/H51/scripts/dataType.js:13:9) at HTMLParagraphElement.onclick (http://localhost:63343/H51/DataType.html:9:38)
這個就是callstack。
JavaScript 教程 之基礎教程