I occasionally write JavaScript, and this JavaScript is invariably littered with bugs. These often boil down to accessing undefined attributes on objects. However JavaScript engines seem very unwilling to error out; instead of falling over my applications stumble on for as long as possible, propagating undefined
values through their state and misbehaving in subtle ways. By the time there is an obvious symptom it often manifests in totally separate component from the actual error (which is sometimes just a typo!).
This is obviously a deliberate and sensible design choice given JavaScript's use-cases, but when developing it's a pain. Are there any techniques for getting my code to fall honourably off its horse in the event of undefined accesses, so that I can help it get back on again?