The a lot of JavaScript you code the a lot of errors you will encounter. this is often a reality of life in any programming atmosphere. Nobody's good and, once your scripts become a lot of complicated, you will find there square measure generally eventualities that end in a slip that you just did not think about.
JavaScript errors on web content will scare your guests away. what number times have you ever encountered an online page with errors, solely to click the "back" button?
OK, therefore you cannot continually forestall errors from occuring, however you'll do one thing concerning them. The JavaScript "Try... Catch" statement helps you handle errors in an exceedingly "nice" approach.
To use the attempt... Catch statement, you are taking any code you're thinking that may doubtless end in a slip, and wrap it inside the "try" statement. You then code what you wish to happen within the event of a slip and wrap that in an exceedingly "catch" statement.
The on top of code can hide the error and gift one thing a lot of user friendly to the user. this is often as a result of the code with the error was wrapped within a "try" statement. And, as a result of there was a slip, the browser outputs no matter is between the "catch" statement.
No comments:
Post a Comment