提前退出功能?

我有一个功能:


function myfunction() {

  if (a == 'stop')  // How can I stop the function here?

}

exit()JavaScript中有类似的东西吗?


SMILET
浏览 310回答 3
3回答

扬帆大鱼

使用一些不同的方法,可以将try catch,和throw语句一起使用。function name() {    try {        ...        //get out of here        if (a == 'stop')            throw "exit";        ...    } catch (e) {        // TODO: handle exception    }}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript