我試圖找出爲什麼我的代碼不會引發並顯示錯誤消息(頁只是空白)後,我把它用下面的語句:JavaScript異常不工作
文件撰寫(添加(10,wrong_input));
program.js
var add = function (a,b){
if(typeof a !== 'number' || typeof b !== 'number'){
throw{
name: 'TypeError',
message: 'add needs numbers'
} catch(e){
document.writeln(e.name + ': ' + e.message);
}
}
return a + b;
}
program.html
您要查找錯誤信息的位置? – Quentin 2013-03-26 20:23:09
你在混合投擲並嘗試。 – bfavaretto 2013-03-26 20:23:28
我在找它可以在瀏覽器中顯示 – Anthony 2013-03-26 20:23:42