what is the best way to procede to prevent this kind of problems?
Personally I quite like
JSLint - takes a bit of getting used to but I think it helps in the end to write stuff that doesn't need the debugging. Just need to choose suitable options and slowly reduce the errors it finds to zero. After a while you will probably get in the habit
of writing stuff that has a lot less errors to begin with. I notice he is starting to exhibit a sense of humour - there is now an option - "Tolerate stupidity !"
If you are writing for the web maybe don't use MSDN as your primary source of information. Find, bookmark and use a few sites that have good cross browser info and come to MSDN to find out why it's not working in IE.
When you use a property, method, event or object etc, look it up. This will slow you down at first but will make you faster in the end.