Java Script : Debugging


In JavaScript debugging can be performed in two ways:

  1. Generating Alerts
  2. Printing in Console

Generating Alerts

By generating alerts in javascript you can check what values are getting the pass, which method is getting executed etc . on the page popup.


var a= 5;

alert(a);

alert("Hello world !!");

When you load you page you will get alert like this:
Java script debug alert

Note : After you testing complete you have to remove these alert statment otherwise duw to lots of alerts, end user will frustrate and that would be bad experience to user.

Printing in Console

For printing console logs help to analyse the execution of statement and values so that how flow got executed.

Syntax :


console.log(statement or text or variable);

Example


  

console.log("Hello World !"); 


For checking debug logs of your page: Press Cntr + F12 function key to you open browser screen then go to console as in below screen.

Java script debug

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s