Intranet Journal Intranet FAQ
Answers
to Questions about...
Troubleshooting JavaScript/JScript
3. What are the most common scripting mistakes?
In his excellent JavaScript Sourcebook,
in a section that begins, "We're only human, after all, and making
misteaks is part of our nature," Gordon McComb identifies eleven
common JavaScript gaffs:
- Omitting quotation marks in Strings
- Mismatched quotation mark types (' and ")
- Omitting quotation marks when comparing strings
- Confusing '=' (assign) and '==' (compare)
- Improperly nested blocks in IF-THEN-ELSE statements
- Trying to write to the script document
- Trying to access forms as a property of a window rather than a
document
- Using String methods with the wrong objects
- Endless loops lock up the browser
- Missing or mismatched '{' or '}' around blocks
- Omitting the return() statement in a function