作者rkt (不能實現的夢)
看板Ajax
標題[ js ] try catch let的問題
時間Tue Jul 1 21:23:48 2008
var actual='';
try
{
try { throw 1; }
catch(e4 if 0) {print("catch e4"); }
catch(e5 if (new NaN)) {print("catcah e5"); }
}
catch(ex)
{
print("catch ex");
actual = ex + '';
}
print(actual);
try
{
z = [1];
let ( x = (undefined ? 3 : z)) { x.t.g }
}
catch(ex)
{
actual = ex + '';
}
print(actual+" 2");
------------------------------
第二次print的結果卻是
e4.t has no property
本來是希望跑出 x.t has no property
想不通為什麼會這樣
變成第一個catch裡面的e4
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.167.17.165
※ 編輯: rkt 來自: 218.167.17.165 (07/01 22:08)
1F:推 fillano:你用的直譯器或引擎??我用js1.8跑不出來你的結果 07/02 01:25
2F:→ rkt:用js1.8可以跑出 x.t has no property的結果嗎 07/02 08:54
3F:→ rkt:我也是用1.8在跑的 07/02 08:57