Well, assuming you're actually interested in learning JavaScript, the best practice is this: Prefer testing by absence/existence of methods and write normalizing functions. So a totally lame example but it hits three principles:
if(!document.getElementsByClassName){
document.getByClass = function(){ //look at all elements, check for class etc...
}
else { document.getByClass = document.getElementsByClassName }
- Don't browser sniff.
- You might as well eliminate a little bit of the DOM cruft as you go. The DOM API's purpose is to be explicit, not to go easy on your carpal tunnel if you've failed to notice how freakishly flexible JS is. The barely-eliminates-any factor is what makes the example lame.
- Cache to a new function. Don't do the method test every time it's called.
The advantage is that you can never 100% trust browser sniffing and you never know when some other library being linked to didn't actually add an equivalent method back in for you.
Whether you're just trying to get stuff done or want to learn more, I recommend JQuery. It does a bang-up job of eliminating DOM API cruft and maintaining a high level of cross-platform normalization but it's also something you can learn a fair bit from studying under the hood. More importantly, if you bother to continue actually learning core JS, it doesn't become useless like so many other JS frameworks and libraries and you'll continue to benefit from being able to de-soupify your JQuery junk with your mad OOP-ish skills.
Also, check out quirksmode.org to understand why Microsoft should be truly despised for all IEs prior to 9 on the JS front and a lot of nitty gritty details on exactly how much is wrong with their proprietary DOM API and suggestions for working around it.