When should you use try/catch in JavaScript?

后端 未结 7 922
旧时难觅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.

    0 讨论(0)
提交回复
热议问题