Skip to main content

toBoolean

Converts any value to a Boolean equivalent.

Note: If no user-defined array is passed, the default true values are:

['true', 'yes', 'y', '1'].

Parameters

  • val any value to check if true or false
  • trueValuesArr array of user defined true values (optional, default true,'true','yes','y','1',1)

Examples

toBoolean('y');
 // => true

toBoolean(null);
// => false

Returns boolean equivalent of the value.

Meta

  • version: 3.1.1