What is Testing?
There is only one way to find out if a script you have written will work properly. You test the script to see if it produces the expected results for a variety of alternative situations.
Types of Error
Ad Hoc Testing
Debugging Using Alert
Commenting Code to Aid Testing
By commenting out part of your script you can narrow down the area of the script that contains a problem.
Validating and Testing
Colour Coding Editors
Formatting and Compressing
For your script to run you want the code compressed/minified as much as possible (but without requiring any script to decompress it before it can run). For actually working on the script and doing the testing a nicely formatted version with plenty of whitespace is better.
Validation Warnings - Should You Fix Them?
Why Ad Hoc Testing May Not Be Enough
When To Develop A Test Plan
Black Box or White Box Testing
Types of Testing
Deciding What to Test
Not all of the paths through your script are necessarily equally likely to occur. How unlikely a particular path is does not necessarily affect your testing.
Expected and Unexpected Values
Which order you run your tests in will affect how likely it is that you will need to rerun lots of tests if one fails.