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 connection in JavaScript.
try/catch
Is try/catch statement useful in JavaScript? When can I use it?
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.
throw
try…catch
2.1m questions
2.1m answers
60 comments
56.9k users