how to use the isboolean function from the underscore library in javascript

The isBoolean function from the underscore library is used to check whether a given value is a boolean or not. Below is an example of how to use the isBoolean function:

index.tsx
const _ = require('underscore');

console.log(_.isBoolean(true)); // Output: true
console.log(_.isBoolean(false)); // Output: true
console.log(_.isBoolean(0)); // Output: false
console.log(_.isBoolean('true')); // Output: false
console.log(_.isBoolean(null)); // Output: false
console.log(_.isBoolean(undefined)); // Output: false
331 chars
9 lines

In the above example, we are importing the underscore library using require and then using the isBoolean function to check whether a given value is a boolean or not. We are passing different types of values to the isBoolean function and checking the output.

The output will be true if the given value is a boolean, otherwise false.

gistlibby LogSnag