Published on: 28 June, 2014

Error Handling and Debugging

Tumblr Digg Google Plus

In early days, it is actually quite hard to debug in Javascript, because there is no proper development tools to cater this issue. Sometimes, erros displayed by browsers are different and it is quite confusing. Luckly, nowadays latest browsers have built in Javascript debugger console to help you finding errors in Javascript codes.

In this tutorial you will learn how you can use a javascript error handling method to tackle an error.

Try and Catch Statement

If you developed in C# or Java, you may be familiar with this code statement, it is just a try catch block code to wrap any content code that you think will possible resulting an error. See code below example.

   // enter your code here.
   // enter an error code handler here.

Debugging in Javascript

To debug in javascript, you can use a keyword console.log, this will basically will print out some text you pass on this parameter. See below code for example.

   // we will print out the error details if there is an error occurs. Note: the console.log print out usually can be viewed in the javascript debugger console.
     var total = 10 + 20;


There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.