Phonegap has a pretty good blog post about this here.
One of the things they mention includes JSLint which I personally use a decent amount. You just post your JS code there and it'll scan for errors and good styling. I also suggest trying to put t the code in a simple html file and run it on the browser. Anything that might seem phone-related, just get rid of it. Its nice to sandbox your javascript on the browser side and then use things like Firebug or Chrome's debugger. (Also I'm sure console.log()
will work there :D)
I've also seen a lot of people mention, including in the blog post, about Weinre so that is something worth checking out.
Other relevant questions that might help:
Phonegap - Javascript debugging in Xcode
iOS PhoneGap debug Workflow
How to see the javascript errors of PhoneGap app in Xcode?
Hope this helps.
EDIT: Found this recently: Debugging in Phonegap