There are many different types of errors you can make on a Web page. The most common errors tend to fit into the following groups:
- Syntax errors, in which the rules of the language are not followed. Examples include not following a JScript function name with parentheses or closing a string with a double quote that was opened with a single quote. Syntax errors are usually fairly easy to track down since they usually cause a descriptive error message to appear.
- Unexpected state errors, in which code encounters a situation that it has not been written to deal with gracefully. Examples include a function that expects numbers only but is passed a string, or a block of code expecting an object or frame to be loaded that has not yet completely loaded. Tracking down these errors ranges in difficulty, depending on the exact error.
- Logic errors, in which valid code is used to do something undesired. Examples include unwitting use of the incorrect formula for calculating tax, or using the incorrect operator (+ instead of -, or = instead of = =) in a math statement. These can be the most difficult types of code errors to debug, as they do not tend to result in overt error messages.
Next we'll look at some common debugging techniques.