mirror of
https://github.com/toss/es-toolkit.git
synced 2024-11-24 03:32:58 +03:00
613 B
613 B
isBoolean
Checks if the given value is a boolean.
This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to boolean
.
Signature
function isBoolean(x: unknown): x is boolean;
Parameters
x
(unknown
): The value to test if it is boolean.
Returns
(x is boolean
): True if the value is boolean, false otherwise.
Examples
const value1 = true;
const value2 = 0;
const value3 = 'abc';
console.log(isBoolean(value1)); // true
console.log(isBoolean(value2)); // false
console.log(isBoolean(value3)); // false