DiviArea.Utils.toBool(value, undefinedValue)

Utility that tests, if a value equals to boolean true.

See below for a list of values that are considered true or false.


value mixed, required
The value which should be converted to a boolean value.
undefinedValue bool, optional
A boolean value to assign if the test value is undefined.
Default: <code>true</code>


Either boolean true or false.


The following values are considered true:

  • true
  • 1
  • string starting with y (like yes)
  • string starting with t (like true)
  • the string on

The following values are considered false:

  • false
  • 0
  • string starting with n (like no)
  • string starting with f (like false)
  • the string off

If the value is undefined the parameter undefinedValue is returned.

Any other value is type-casted to boolean by JavaScript.

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Get in touch with us