DiviArea.Utils.toBool()

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.

Params

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>

Returns

Either boolean true or false.

Notes

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

Contents