Luckily browser tests aren't as necessary anymore as they used to be. But there are still situations where you going to need them. For example when using a feature only available and only needed in it (like in an hybrid app).

Here is a simple expression to check for Safari:

var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);