|
|
|
|
|
|
|
|
Intranet Journal Intranet FAQ
JavaScript FAQ
Answers
to Questions about... 2. Where can scripts go wrong?There are three distinct areas where errors can occur in any computer program:
Load-time errors Load-time errors are caught by the JavaScript interpreter. As the browser loads your script, it performs myriad checks for basic language problems -- usually syntax errors. If, for instance, you leave off the closing half of a pair of parentheses, the interpreter will tell you about it in the form of a load-time error. Why? Because a script can't run until it has loaded successfully. By checking your scripts in two browsers -- Netscape Navigator 3.0
(or later) and Microsoft Internet Explorer 3.0 (or later) -- you leverage
the language- Run-time errors When a program is running it manipulates stored data, operating on values in memory as specified by program commands. Thus, whereas errors occur at load time chiefly due to bad syntax, run-time errors are often due to misuse of the language's commands. For instance, you'll get a run-time error if at some point your script divides by zero (illegal in any language). Logic errors The best way to verify your program logically is to stress it. You probably won't be able to exercise all the possible inputs, outputs, if-then statements and loops, but by hitting a few major ones, you gain confidence that any errors are at least well hidden. If and when these occur, of course, they may be equally hard to trace. But that's software for you.
|