Skip to content

Do you know how to debug your JavaScript

    debugger – debugger key word in JavaScript stops the Js code and calls (if available) the debugging function. If no debugging is available the “debugger” key word does not have any effect on the code.

     

    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 also set breakpoints (places where code execution can be stopped), and examine variables while the code is executing.

    Normally, otherwise follow the steps at the bottom of this page, you activate debugging in your browser with the F12 key, and select “Console” in the debugger menu.

    The console.log() Method

    If your browser supports debugging, you can use console.log() to display JavaScript values in the debugger window:

    Example: