JavaScript Programming: Debugging
Learning JavaScript can be liberating, even fun. Scripting gives
you the power to make your pages more dynamic and interesting.
Best of all, its flexibility lets you add your own touches to
personalize your page. If you've been following along in this
series and--I hope--experimenting and testing out your own ideas
about what might or might not work, you have more than likely
already encountered your first error message.
You know what I'm
talking about. You plan the perfect script for hours, check and
double-check the documentation, enter the code in carefully bracketed
<SCRIPT> tags, recheck your brilliant logic, save out the
HTML file and load it into your browser, prepare to be dazzled,
and...your ungrateful browser comes back:
Netscape - (Alert) JavaScript Error:
script.html
,
line 40
syntax error
else
. . . . . . . . . . . ^
If you've programmed in C, Basic, or another scripting language,
you're likely to sigh and dig in. Here we go again. If you're
new to programming, however, these error messages can be frustrating
and discouraging. This article gives you an overview of the
debugging process and some tips that will serve you well here,
as well as elsewhere in your programming life.
What is a Bug?
A bug is an instruction in a program that is causing an undesirable
result. There are two main types of bugs: Syntax and logic errors.
Syntax errors happen when you say something the computer doesn't
understand, causing program interpretation to stop. Logic errors
are when the program works, but doesn't do what you thought you
meant.
[Move on the Part II]
Web Developer® Site Feedback
Web Developer®
Copyright © 2000 internet.com Corporation. All rights reserved.