1. Using Console.log:
To use Console.log, you can simply write "console.log(variable_name)" in your code where you want to log the value of the variable.
var x = 5; console.log(x); // Output: 5
2. Using Breakpoints:
Breakpoints can be used to set stopping points in the code, where the code execution will be paused at the specified point. This can help in examining the values of variables and objects during the execution of the code.
To set a breakpoint, you can simply click on the line number where you want to set the breakpoint in the code editor. When the code execution reaches that line, it will be paused and you can examine the values of different objects and variables.
3. Using Debugger:
Debugger is a built-in tool in web browsers that allows developers to set breakpoints and monitor the values of variables and objects during the execution of the code. It can be used to identify and fix errors in the code.
To use Debugger, you can add the keyword "debugger" in your code where you want to set the breakpoint.
var x = 5; debugger; // Execution will be paused at this line x = x + 2; console.log(x); // Output: 7
4. Using Debugging Libraries:
In addition to using these tools, it is important for developers to avoid errors in the code and perform debugging regularly to ensure that the code is working as expected.
Example using HTML:
In this example, the value of variable "x" is logged in the console using the Console.log tool.