Tag Archives: java script alert

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