VDL Plugin SDK

isBoolean

Import from @varavel/vdl-plugin-sdk/utils/predicates.

function isBoolean(x): x is boolean;

Checks if the given value is boolean.

This function tests whether the provided value is strictly boolean. It returns true if the value is boolean, and false otherwise.

This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to boolean.

Parameters

ParameterTypeDescription
xunknownThe Value to test if it is boolean.

Returns

x is boolean

True if the value is boolean, false otherwise.

Example

const value1 = true;
const value2 = 0;
const value3 = 'abc';

console.log(isBoolean(value1)); // true
console.log(isBoolean(value2)); // false
console.log(isBoolean(value3)); // false