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