I'm trying to debug a BIRT report where I've retrieved a paramter from the reportContext like so: var myParameter = reportContext.getParameterValue("myParameter");
BIRT has no debugger and BIRT javascript cannot access JSON.stringify, so I cannot examine what this variable is except by printing it. When I print it, it prints as "false". typeof(myParameter)
is "object", myParameter === null
evaluates to false, myParameter === undefined
evaluates to false, myParameter == "false"
evaluates to false, and myParameter is truthy (if I use it as the guard to an if statement, the if statement is executed). What the heck is this variable, and how can I determine what it is? Is there a way to stringify it without using JSON.stringify, which I cannot access in BIRT?
> new Boolean(false).toString()
'false'
> typeof new Boolean(false)
'object'
> !!new Boolean(false)
true
>
To check whether this is in fact your object, new Boolean(false).constructor
returns (stringified) [Function: Boolean]
.
SLaks给出的答案非常接近,并让我弄清楚它到底是什么:BIRT javascript可以调用Java代码并使用Java对象和类 - myParameter是BIRT的Java布尔对象的Javascript版本(不是Java布尔基元,或Javascript布尔对象,或Javascript布尔基元)。
Consider some custom object with a custom toString()
function with the latter returning false.
function MyType() {} MyType.prototype.toString = function() { return "false"; }; var a = new MyType(); console.log( String( a ) ); console.log( typeof a ); console.log( Boolean( a ) );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.