Skip to main content
Version: Next

is.safari

is.safari(target: unknown)โ€‹

The is.safari method is used to determine if the current browser is Safari.

It's worth noting that this method does not differentiate between mobile and desktop versions of Safari. To check specifically for mobile Safari, you can use the is.ios method.

Specificationโ€‹

  • Target argument: optional.
  • Return: boolean.

Informationโ€‹

  • Unit tests: โœ…

Examplesโ€‹

is.safari() // true if the command is executed in the safari browser
is.safari('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36') // true

// Alternative
isConfig.state.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36';
is.safari() // true


// Recomendation
is.browser_safari();

is.safari(false) // false
is.safari(new Boolean(0)) // false
is.safari(new Boolean()) // false
is.safari(0) // false
is.safari('') // false
is.safari({}) // false
is.safari([]) // false
// And all other known types will return false

Reversal boolean resultโ€‹

is.not_safari() // false if the command is executed in the safari browser
is.not_safari('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36') // false

// Alternative
isConfig.state.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Safari/537.36';
is.not_safari() // false


// Recomendation
is.not_browser_safari();

is.not_safari(false) // true
is.not_safari(new Boolean(0)) // true
is.not_safari(new Boolean()) // true
is.not_safari(0) // true
is.not_safari('') // true
is.not_safari({}) // true
is.not_safari([]) // true
// And all other known types will return true