Unless the Javascript that you are writing is only one or two lines long then there is a good chance that you will not get the code exactly right on the first attempt. This is particularly true if your code needs to access the web page since the different web browsers have their own various quirks as to how they handle certain code.
To assist you in working out when an error has occurred, each of the different web browsers supplies an error message facility to tell you where the error occurred.
In Internet Explorer this facility either pops up automatically unless you have set Disable Script Debugging in the Browseing section of the Advanced tab of Internet Options. If it is disabled and a Javascript error occurs then a message "Done with Errors" appears in the status bar. Double clicking on the message will open the error message box allowing you to see where IE detected the error and what the associated error message is.
Onter web browsers contain a similar facility but don't provide a way to have the errors pop up automatically. Instead you must open the Javascript Console separately to view the error messages there. You will find the console in the Tools menu of Firefox. In Mozilla and Netscape it is one level lower down as you need to select Web Development from the Tools menu. In Opera it is also one level lower within the Advanced options.
One problem with just getting the error message(s) at the time the browser detected the error is that where the browser decided that there is an error in the code is not necessarily the spot in the code where the error actually is since an error in one spot can affect how all of the subsequent code on the page is treated. Getting the error message(s) is a step in the right direction but may not get you right to the actual error.
If you are getting really stuck trying to work out where the error is then you need a proper debugger that will allow you to trace the processing statement by statement and check the values held in variables as required. Fortunately the Mozilla browser (as well as Netscape 6+) supply us with such a facility within the browser itself. To access Venkman (as this debugger is called) you simply need to select Javascript Debugger from within the Web Development option in the Tool menu.

