alert()
The alert() function is your most useful tool for debugging errant scripts.
For example:
alert("About to send the enter key");
alert("The value of x is " + x.toString());
alert("The customer number is " + objGlobal.CustomerNumber);
Also See
Strange behavior in scripts
Object expected