But, should we use a browser detect, if we want to know whether the browser that will render our page, supports certain objects that we want to use in our code in JavaScript?
The answer is no, we should should never ever use a browser detect.
Why should we not use a browser detect?
90% of our browser detection may work fine but there is also a probability of some obscure browsers not being treated correctly and browsers that appear after we have written the page not being adequately covered either. This may result in either stream of error messages. There is also a chance that though there is a script available that can be handled by the browser, but yet that script is not called.
We know that there are web standards, so that we don't have to write specific code for specific environments. Therefore we need to write codes that adhere to established standards, instead of using browser specific scripts.
What should we do instead?
We should check if the browser supports the object (method, array or property) we want to use instead of detecting the browser that the viewer is using.
The answer is: use Object detection.
Read more here about Object detection .