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.


(mixed, required) The value which should be converted to a boolean value.
(bool, optional) A boolean value to assign if the test value is undefined.
Default: true


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.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.