Finding Problems in Your JavaScript Code
- Use Firefox Error Console (Tools Error Console)
- Use JS Closure Compiler (JS Closure Compiler)
- Check for commonly found errors
- Semicolon after while expression (e.g., while(x < 2); { }
- Semicolon after if expression (e.g., if (x < 2) ; { }
- Missing ; in for loop
- Variable not initialized
- Incorrect use of || in expression (e.g., x = 2 || 4)
- Using = instead of == or === in expression (e.g., if (x = 2))
- Naming local variable after the function
- Getting "undefined"?
- Make sure your functions return a value
- Make sure your variables are initialized
- Make sure you are not getting out of the bounds of the array
- Array Related
- Incorrect loop termination expression (e.g., (for (i= 0; i<= a.length; i++))
- Assuming array duplication is done by assignment (e.g., a = b))
- Make sure you spell length correctly when accessing the length of an array
- Make sure you are not getting out of the bounds of the array
- Trace your code using Firebug (http://getfirebug.com/)
Web Accessibility