NAME

JSPL::Boolean - Perl class that encapsulates the JavaScript's true and false values.

DESCRIPTION

In JavaScript, every boolean expression results in one of the two values true or false. Both values, when returned to perl space will be wrapped as instances of JSPL::Boolean. Both perl objects use the overload mechanism to behave as expected.

As in JavaScript the rules to convert other values to boolean values are similar to perl's ones, you seldom need to think about them. But, although is considered bad style, you can found JavaScript code that uses something like the following:

    function foo(val) {
	if(val === true) {
	    ...
	}
    }

So the need arises to be able to generate true JavaScript boolean values from perl. In those cases you can use the class methods described next.

Class methods

True

Return an object that when passed to JavaScript results in the true value, and when evaluated in a perl expression gives a TRUE value.

my $realJStrue = JSPL::Boolean->True;

The same object that constant "JS_TRUE" in JSPL.

False

Return an object that when passed to JavaScript results in the false value, and when evaluated in a perl expression gives a FALSE value.

my $realJSfalse = JSPL::Boolean->False;

The same object that constant "JS_FALSE" in JSPL.