One thing that is driving me nuts is how Javascript fails silently in many different situations.
(removed example because it confuses the point of my question)
Many times I have come across an error that will give an error message when typed into the Firebug console, but when it runs within the page script, it fails silently, even with the Firebug console active and open!
Some of these problems can be caught by Crockford's JsLint, but still many won't.
Isn't there a way to enable more error messages in the browser?
Can you do this at all without using javascript debugger environments? I find debuggers don't help me much. I usually sprinkle a few console.log() statements and can locate the problem in a minute. What drive me nuts is that silent errors in Javascript can go unnoticed for a long time, or show up in ways that are not obvious at all. It's even more frustrating because testing the statement in the console DOES give an error, so what's going on?
I have had the same problem with exceptions by the way, did anyone notice this? Often times my throw new
statements don't work at all. But if I type the same thing in the console, it does.
Thanks for your helpful comments (first answers), but that is not my question. These tests are useful when you need to sanitize parameters to a class for example, when you don't know for sure about the environment. You don't want to test for existence of properties or classes where you expect them to be there; that would be bloating the code for no reason.