Skip to main content
Version: 1.0.2

is.even

is.even(target: unknown)โ€‹

The is.even() method provides a simple and convenient way to check if a number is even. It is useful in situations where you need to validate user input, perform calculations, or perform other operations based on the parity of a number. With its simple syntax and robust error handling, is.even() is a great tool to have in your JavaScript toolkit.

Specificationโ€‹

  • Target argument: required.
  • Checks if the given "target" type is even.

Informationโ€‹

  • Unit tests: โœ…

Examplesโ€‹

is.even(0) // true
is.even(2) // true
is.even(-2) // true
is.even(BigInt(2)) // true
is.even(2n) // true
is.even(-32n) // true

is.even(BigInt(1)) // false
is.even(1) // false
is.even(-1) // false
is.even('undefined') // false
is.even('null') // false
is.even(Symbol()) // false
is.even(null) // false
is.even(true) // false
is.even([]) // false
is.even(false) // false
is.even("") // false
is.even('') // false
is.even(``) // false
is.even({}) // false
is.even(undefined) // false
is.even(Function) // false
is.even(() => {}) // false
is.even(BigInt) // false
is.even(Symbol) // false
is.even(NaN) // false
is.even(Infinity) // false
is.even(-Infinity) // false
is.even(Number.POSITIVE_INFINITY) // false
is.even(Number.NEGATIVE_INFINITY) // false
// And all other known types will return false

Reversal boolean resultโ€‹

is.not.even(0) // false
is.not.even(2) // false
is.not.even(-2) // false
is.not.even(BigInt(2)) // false
is.not.even(2n) // false
is.not.even(-32n) // false

is.not.even(BigInt(1)) // true
is.not.even(1) // true
is.not.even(-1) // true
is.not.even('undefined') // true
is.not.even('null') // true
is.not.even(Symbol()) // true
is.not.even(null) // true
is.not.even(true) // true
is.not.even([]) // true
is.not.even(false) // true
is.not.even("") // true
is.not.even('') // true
is.not.even(``) // true
is.not.even({}) // true
is.not.even(undefined) // true
is.not.even(Function) // true
is.not.even(() => {}) // true
is.not.even(BigInt) // true
is.not.even(Symbol) // true
is.not.even(NaN) // true
is.not.even(Infinity) // true
is.not.even(-Infinity) // true
is.not.even(Number.POSITIVE_INFINITY) // true
is.not.even(Number.NEGATIVE_INFINITY) // true
// And all other known types will return true