Most of the time developers uses alert('message'); to debug the JavaScript. But its not that much efficient because whenever you want to change the property of an object you have to change the code & re-run the application.
One keyword available in JavaScript which will enable us to debug the JavaScript as we do in our .Net (will have intellisense), by this we can see all the properties & function available in the object.
Steps to Debug JavaScript:
- Identify the debugging point & place 'debugger;' keyword in the JavaScript code.
- Open IE (Internet Explorer) - Go to Tools -->Internet Options -->Advanced Tab
- Deselect the below mentioned two check boxes.
- Run the application (for which you want to debug). If you are developing .Net application Visual Studio .Net IDE will automatically jumps to debugger position. Start using the intellisense & resolve you issues.
- If you are not using Visual Studio IDE, one window will prompt to select debugger engine with all available JavaScript debugger engines in you system. Some times even Visual Studio IDE will also prompt for the debugger.
- Select any of the Debugger engine and start debugging the JavaScript.