Published on: 28 June, 2014

Error Handling and Debugging

Posted by andy | 1407 views 1 likes 0 favourites 0 comments
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.
Related Articles
Published on: 20 June, 2016
Google Analytics is one of the best free analytics site tracker. It gives you an idea the statistic of your visitors like the country they come from, the URL or keyword they search to go to your site or even the demographic or ages of your visitors. If you are a developer, you definitely do not want to track any data when you are in development phase. In this tutorial, you will learn how to disable google analytics for local development by using a javascript code if condition.
Published on: 13 May, 2016
To convert a number value into money format in Javascript can be done easily using Javascript. Firstly you will need to use the built in toFixed function that will return a number value into two decimal point and then using a regular expression to reformat the value.