Skip to main content
Version: 1.0.2

is.mobile

is.mobile()โ€‹

The is.mobile method is typically used to determine whether the current device is a mobile device or not.

Specificationโ€‹

  • Return: boolean.

Informationโ€‹

  • Unit tests: โœ…

Data used for examples

const userAgent = 'Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.1.0.342 Mobile Safari/534.11+';

Examplesโ€‹

is.mobile() // true if the command is executed in a browser running on the mobile
is.mobile(userAgent) // true

// Alternative
IsConfig.state.userAgent = userAgent;
is.mobile() // true

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

Reversal boolean resultโ€‹

is.not.mobile() // false if the command is executed in a browser running on the mobile
is.not.mobile(userAgent) // false

// Alternative
IsConfig.state.userAgent = userAgent;
is.not.mobile() // false

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