When you call a script with language="cache" and returntype="%Boolean" from a javascript script, the return value is interpreted as a string, not as a boolean.
Here's an example:
A cache script that returns (in theory) a "false" value:
<script language="cache" method="giveMeAFalse" arguments="" returntype="%Boolean" procedureblock='1'>
return
</script>
A javascript method that logs what the value's actually interpreted as:
function isItActuallyFalse() {</p>
var bool = #server(..giveMeAFalse());
console.log("bool ? 'truthy':'falsy' = "+(bool ? 'truthy':'falsy'));
console.log("typeof bool = ", typeof bool);
}</p>
</script>
Output:
bool = 0
bool ? 'truthy':'falsy' = truthy
typeof bool = string
So bool is actually the string: "0", rather than the integer 0, or the boolean false. Therefore, since bool is a string, it evaluates to truthy in Javascript, regardless of its contents. Keep this in mind when returning values from cache methods into javascript methods.
If anyone knows of official documentation of this behavior somewhere, definitely link it. I'm posting this so the next person who searches something like "cache script return type javascript csp" will hopefully hit some keywords, so it would be great if that hypothetical person also found an extended, official discussion of it.
Cheers.
</body></html>