Skip to main content
Version: 1.0.1

is.firefox

is.firefox(target: unknown)​

The is.firefox method is a function that takes an argument and returns a boolean indicating whether the argument is an instance of the Firefox browser. This method can be useful in determining the browser being used, and can be used for browser-specific feature detection.

The implementation of is.firefox typically involves checking the navigator.userAgent property for the string "Firefox". If the string is found, the method returns true; otherwise, it returns false.

This implementation takes a userAgent argument, which is a string representing the user agent of the browser. It checks whether the string "Firefox" is present in the user agent string using the indexOf method, and returns true if it is, and false otherwise.

In some cases, it may be necessary to use a more robust implementation of browser detection that takes into account browser version numbers, as well as platform-specific differences. However, for simple cases where only a few specific browser types need to be detected, a method like is.firefox can be sufficient.

Specification​

  • Target argument: optional.
  • Return: boolean.

Examples​

is.firefox() // true if the command is executed in the firefox browser
is.firefox('Mozilla/5.0 (Android; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0') // true

// Alternative
isConfig.state.userAgent = 'Mozilla/5.0 (Android; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0';
is.firefox() // true

// Recomendation
is.browser.firefox();

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

// Reversal boolean result

Reversal boolean result​

is.not.firefox() // false if the command is executed in the firefox browser
is.not.firefox('Mozilla/5.0 (Android; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0') // false

// Alternative
isConfig.state.userAgent = 'Mozilla/5.0 (Android; Mobile; rv:68.0) Gecko/68.0 Firefox/68.0';
is.not.firefox() // false

// Recomendation
is.not.browser.firefox();

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