isBoolean

Test if a value is a boolean.

Usage

var isBoolean = require( '@stdlib/assert/is-boolean' );

isBoolean( value )

Tests if a value is a boolean.

var bool = isBoolean( false );
// returns true

bool = isBoolean( true );
// returns true

bool = isBoolean( new Boolean( false ) );
// returns true

bool = isBoolean( new Boolean( true ) );
// returns true

isBoolean.isPrimitive( value )

Tests if a value is a primitive boolean.

var bool = isBoolean.isPrimitive( true );
// returns true

bool = isBoolean.isPrimitive( false );
// returns true

bool = isBoolean.isPrimitive( new Boolean( true ) );
// returns false

isBoolean.isObject( value )

Tests if a value is a Boolean object.

var bool = isBoolean.isObject( true );
// returns false

bool = isBoolean.isObject( new Boolean( false ) );
// returns true

Examples

var isBoolean = require( '@stdlib/assert/is-boolean' );

var bool = isBoolean( false );
// returns true

bool = isBoolean( new Boolean( false ) );
// returns true

bool = isBoolean( 'true' );
// returns false

bool = isBoolean( null );
// returns false
Did you find this page helpful?