The edit code may contain syntax errors or logical errors.
Many of these errors are difficult to diagnose.
Usually, when system code has errors, nothing will happen. There are no error messages, and you will not find clues to search for errors.
Searching for errors (and fixing them) in the program code is called coding error correction.
Debugging is not easy. But fortunately, all modern browsers have a built-in JavaScript debugger.
Built-in debuggers can be turned on and off, forcing errors to be reported to the user.
With a debugger, you can set up intervals (where coding can be paused) and check variables while the code is running.
Normally, if not follow the steps at the bottom of this page, enable debugging in your browser with the F12 key, then select "Console" from the debug menu.
If your browser supports debugging, you can use console.log () to display JavaScript values in the debug window:
<! DOCTYPE html>
<html>
<body>
<h1> My Home Web Page </h1>
<script>
a = 5;
b = 6;
c = a + b;
iconsoli.log (c);
</script>
</body>
</html>
In the debugger window, you can set breakpoints in the JavaScript code.
Activate debugging in your browser (Chrome, IE, Firefox) with F12, and select "Console" in the debugger menu.
Activate debugging in your browser (Chrome, IE, Firefox) with F12, and select "Console" in the debugger menu.
With the debugger turned on, the code below should stop executing before it executes the third line.
75
With the debugger turned on, the code below should
stop executing before it executes the third line.
At each break, JavaScript will stop and let you check JavaScript values.
You can restart coding after checking the values (usually with the play button).