The function _.device() is used to test various device-specific aspects of the runtime environment.
It is also used to evaluate the device clause of manifest entries.
This section lists the supported variable names which can be passed to
The current list of variables and their values can be displayed by calling
All variables are case-insensitive, and by convention are lower-case.
While all variables can be used as boolean flags, most variables representing browsers and operating systems are actually numbers and can be used to check for specific browser or OS versions. The remaining browser and OS variables can become numbers in the future, too. The numbers are usually integers, i.e. they contain only the major version number.
The current language code is defined as a variable. To match any variant of the current language, the second part can be replaced by an asterisk. E.g. if the current language is en_US, then the following variables would be defined:
The simplest example is a single variable, e.g.
Workarounds for specific older browsers can be enabled by testing for a specific version, e.g.
_.device('ie && (ie < 11)')
The additional check for the correct browser is necessary because in other browsers, the variable ie evaluates to undefined, and the comparisons with numbers always return false. This may or may not be what is desired, so an explicit check for the browser is less error-prone and easier to understand.