Home > Articles > Programming > JavaScript

An Introduction to JavaScript Debugging

  • Print
  • + Share This
Novice programmers, or those migrating from other languages, usually find the JavaScript language fairly accessible, with plenty of available help and advice on how to get started developing programs. Unfortunately, the many articles and tutorials on coding rarely give much advice on what to do when code doesn't run correctly. In this article, Phil Ballard, author of Sams Teach Yourself JavaScript in 24 Hours, 5th Edition, introduces some simple but valuable methods for analyzing and debugging your JavaScript code, to make your programming time more productive and less frustrating.
Like this article? We recommend


Whether you just started out in JavaScript programming or are a seasoned coder, you'll no doubt have spent time seeking out gremlins in your JavaScript source code. The process of locating and correcting bugs is known as debugging, and it can be one the most tricky and frustrating parts of the development process.

The sort of errors that can crop up in your code usually conform to one of three types:

  • Syntax Errors: These can include typographical and spelling errors, missing or mismatched quote marks, missing or mismatched parentheses/braces or case-sensitivity errors.
  • Runtime Errors: These errors occur when the JavaScript interpreter tries to do something it can't make sense of. Examples include trying to treat a string as if it were a numerical value, or trying to divide a number by zero.
  • Faulty Program Logic: These mistakes don't always generate error messages—the code may be perfectly valid—but your script doesn't do what you want it to. These are usually problems associated with algorithms or logical flow within the script.

This article aims to offer some straightforward tips and suggestions for debugging your code, making your programming hours more pleasurable and productive.

  • + Share This
  • 🔖 Save To Your Account