I can think of at least a few possibilities for you. One of them is JSLint, as mentioned above. Another is to use a new Javascript function called "strict mode" ( described here among other places )
I heard that Firefox nightly builds now support strict mode, as well as pre-release versions of Chrome. Soon, all new browser versions will support it.
source share