Determines the value of the passed object and returns the corresponding Boolean value.

Syntax

JSV_toBoolean(expV)

Prototype

n/a

Returns

The JSV_toBoolean function returns all non-zero values as true and zero values as false.

Parameters

The toBoolean function uses the following argument.

Argument Description
expV Any value.

Remarks

Zero values include null, 0 (number and string), "No" (case insensitive), false (Boolean and string) and a zero length string; all other cases are non-zero values.

In Cold Fusion, "Yes" is true and "No" is false. This function allows the programmer to convert these values into their Boolean equivalents for use in a JavaScript function.

Dependencies

n/a

Example

The following lines of code

var tc = "098";
document.write( tc + " is Boolean " + JSV_toBoolean(tc)  );
tc = 0;
document.write( tc + " is Boolean " + JSV_toBoolean(tc)  );
tc = "YeS";
document.write( tc + " is Boolean " + JSV_toBoolean(tc)  );
tc = "nO";
document.write( tc + " is Boolean " + JSV_toBoolean(tc)  );
tc = true;
document.write( tc + " is Boolean " + JSV_toBoolean(tc)  );

produce