Lodash _.isBoolean() Method
Last Updated :
25 Oct, 2023
Lodash _.isBoolean() method checks if the given value can be classified as a Boolean value or not.
Syntax:
_.isBoolean(value);
Parameters:
- value: This parameter holds the value that needs to be Checked for Boolean.
Return Value:
This method returns a Boolean value(Returns true if the given value is a boolean, else false).
Example 1: In this example, the _.isBoolean() method returns true when the value is a boolean(true or false).
Javascript
const _ = require( 'lodash' );
let val = true ;
console.log( "The Value is Boolean : "
+ _.isBoolean(val));
let val1 = false ;
console.log( "The Value is Boolean : "
+ _.isBoolean(val1));
|
Output:
The Value is Boolean : true
The Value is Boolean : true
Example 2: In this example, the _.isBoolean() method returns false when the value is a null value.
Javascript
const _ = require( 'lodash' );
let val = null ;
console.log( "The Value is Boolean : "
+ _.isBoolean(val));
|
Output:
The Value is Boolean : false
Note: This will not work in normal JavaScript because it requires the lodash library to be installed.
Share your thoughts in the comments
Please Login to comment...