is.android-phone
is.androidPhone(target: unknown)โ
The is.androidPhone
method returns a boolean value of true
if the device accessing the application is an Android phone and false
otherwise. This method uses the navigator.userAgent
property to check the user agent string of the device and determine whether it is an Android phone.
Specificationโ
- Target argument: optional.
- Return: boolean.
Informationโ
- Unit tests: โ
Data used for examples
const userAgent = 'Mozilla/5.0 (Linux; Android 11; Pixel 4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Mobile Safari/537.36';
Examplesโ
is.androidPhone() // true if the command is executed in a browser running on the androidPhone
is.androidPhone(userAgent) // true
// Alternative
IsConfig.state.userAgent = userAgent;
is.androidPhone() // true
is.androidPhone(769) // false
is.androidPhone(false) // false
is.androidPhone(new Boolean(0)) // false
is.androidPhone(new Boolean()) // false
is.androidPhone(0) // false
is.androidPhone('') // false
is.androidPhone({}) // false
is.androidPhone([]) // false
// And all other known types will return false
Reversal boolean resultโ
is.not.androidPhone() // false if the command is executed in a browser running on the androidPhone
is.not.androidPhone(userAgent) // false
// Alternative
IsConfig.state.userAgent = userAgent;
is.not.androidPhone() // false
is.androidPhone(769) // true
is.androidPhone(false) // true
is.androidPhone(new Boolean(0)) // true
is.androidPhone(new Boolean()) // true
is.androidPhone(0) // true
is.androidPhone('') // true
is.androidPhone({}) // true
is.androidPhone([]) // true
// And all other known types will return true