Skip to main content
Version: 2.0.3

is.phone

is.phone(target: unknown)โ€‹

The is.phone method is not a built-in method in JavaScript or any popular libraries like Lodash or Underscore. However, you can create your own custom function to determine if a device is a phone or not based on certain criteria.

One possible approach is to use the user agent string provided by the browser and check if it contains any phone-related keywords.

Specificationโ€‹

  • Target argument: optional.
  • Return: boolean.

Informationโ€‹

  • Unit tests: โœ…

Examplesโ€‹

is.phone() // true if the command is executed in the browser with screenWidth <= 768
is.phone(768) // true

// Alternative
IsConfig.state.screen.width = 768;
is.phone() // true

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

Reversal boolean resultโ€‹

is.not_phone() // false if the command is executed in the browser with screenWidth <= 768
is.not_phone(768) // false

// Alternative
IsConfig.state.screen.width = 768;
is.not_phone() // false

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