When should you use try/catch in JavaScript?

后端 未结 7 988
旧时难觅i
旧时难觅i 2021-01-30 00:53

When I\'m developing normal web application with JavaScript, the try/catch statement is not needed usually. There\'s no checked exception, File IO or database conne

7条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-30 01:52

    Use it whenever code you are running might throw an exception. Remember that you can throw your own errors — most of the try…catch stuff I use is for catching my own exceptions.

提交回复
热议问题