NAME
JSP::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 JSP::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, althought is considered bad style, you can found javascript code that uses something like the following:
function foo(val) {
if(val === true) {
...
}
}
So the need arise to generate from perl true javascript boolean values, 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 = JSP::Boolean->True;
The same object that constant "JS_TRUE" in JSP.
- 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 = JSP::Boolean->False;
The same object that constant "JS_FALSE" in JSP.