codegurukool.com · Free coding tutorials & online compiler

Home › JavaScript Tutorial › JS debugging

JS debugging

Find bugs.

Open the browser developer tools (F12). Use console.log, console.table, console.error, breakpoints and the debugger statement.

Commands in this lesson

console.log

Definition: Prints a value for debugging.

Syntax:

console.log(value);

Example:

console.log("Sum:", 2 + 3);

Example code

<p id='o'>Open DevTools (F12) on your own page to see the console.</p>
<script>
console.table([{a:1,b:2},{a:3,b:4}]);
console.error('Something went wrong');
// debugger;  // pauses when DevTools is open
</script>

Run this code in the online editor

← JS errorsJS style guide →