在JavaScript中,Python的“尝试...除外”功能是否有效?

时间:2016-11-01 10:09:33

标签: javascript

以下是我试图在JavaScript中解决此问题的Python代码:

fopen

我正在寻找与Python中“except”等效的关键字。

1 个答案:

答案 0 :(得分:1)

在javascript中,我们有trycatchfinally

try {
   //may throw
} catch(ex) {
   //handle the error, where ex or what ever you choose to call it is your exception reference
} finally {
   //perform this code regardless
}