Skip to content

@technobuddha > library > Object > Type Guards

Function: isBoolean()

ts
function isBoolean(value: unknown): value is boolean;

Defined in: is-boolean.ts:16

Determines whether the provided value is a boolean or a Boolean object.

Parameters

ParameterTypeDescription
valueunknownThe value to test.

Returns

value is boolean

True if the value is a primitive boolean or a Boolean object; otherwise, false.

Example

typescript
isBoolean(true); // true
isBoolean(false); // true
isBoolean(new Boolean(false)); // true
isBoolean(0); // false
isBoolean('true'); // false