Skip to main content
Version: 1.0.1

is.mobile

is.mobile()​

Specification​

  • Return: boolean.

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