Firefox's JavaScript tools are great for this sort of thing. It's why I tend to do JavaScript stuff in Firefox/Mozilla first; I use it to weed out basic errors in my code, and then once that's done I test it in other browsers and tweak it if I have to. It makes things go a lot faster..
Mozilla has the console too, if you prefer to use that. Safari has something similar, but it's pretty well-hidden. You have to enable the Debug menu, then tell it to log JavaScript errors, then open Console.app (not to be confused with Terminal.app) and look for the errors there.