Improve my browser-detecting JavaScript
"Browser-sniffing" is bad, usually because the methods used to detect them are usually "spoofable" and unreliable

User Agent string can be spoofed (changed) and can't be relied on. In fact, vendors change UAs to tell websites they are another browser, some for valid purposes. I think it was IE10 who added a "Mozilla" to their UA to tell websites to load non-IE versions of pages, with confidence that the newer IE will render "unhacked"/not modified for IE pages without breaking.

Even if you UA strings are fixed, you can't keep track of the 70+ (I think it was 70+, or something with a 7) different browsers in the wild today. Yes, there are browsers other than the major 5, like mobile browsers, command-line browsers, headless browsers. And don't forget to count the older versions, do still use them.

Recently, developers use feature testing instead, to check if certain features are available in the browser. Modernizr is an example of such frameworks.