我是JavaScript的新手,但对于编程/脚本编程并不陌生,我对throw
个例外有疑问。
所以,我想知道的是else
例外的throw
语句。
E.g
// More code above
try
{
if(i=="something") {
throw "'i' equals 'something'."
}
else
{
throw "'i' doesn't equal 'something'."
}
}
// More code here
这样的事情可能吗?
答案 0 :(得分:2)
您可能正在寻找finally
关键字
try
{
if(i=="something") {
throw "'i' equals 'something'."
}
else
{
throw "'i' doesn't equal 'something'."
}
} catch( ex ) {
// your exception handling code
} finally {
// Statements that are executed after the try statement completes.
}