Prevent Javascript stop working when error occurred - suppress errors

Is it possible to suppress Javascript errors ? How can I prevent the script from stop working when there is an error occurred ? I want script with error to continue execution.
0
give a positive ratinggive a negative rating
Hi,

In Javascript, there is not an option to suppress error, like it is PHP, where you use "@".

But there is a way how to get similar behaviour in Javascript. It requires to develop the code, that expects a certain errors.

You can check if each function can be performed (validate it). To do the check, you have to use try / catch statements and typeof in condition, with strict equality operator ===.

For a files, you can use onerror event, which is triggered if an error occurs, while loading an external file.

Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2025 AnswerTabsTermsContact us