我有一个功能:function myfunction() { if (a == 'stop') // How can I stop the function here?}exit()JavaScript中有类似的东西吗?
3 回答

扬帆大鱼
TA贡献1799条经验 获得超9个赞
使用一些不同的方法,可以将try catch,和throw语句一起使用。
function name() {
try {
...
//get out of here
if (a == 'stop')
throw "exit";
...
} catch (e) {
// TODO: handle exception
}
}
添加回答
举报
0/150
提交
取消