Skip to main content
Version: 1.0.2

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