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
24 Nov 2021 at 07:24 PM
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.

0
give a positive ratinggive a negative rating
30 Jun 2023 at 10:15 AM
Tim
Share on FacebookShare on TwitterShare on LinkedInSend email
x
x
2024 AnswerTabsTermsContact us