Say I’m accessing a JavaScript Object called jso in Java and I’m using the following statement to test if it’s null
if (jso == null)
However, this statement seems to return true when jso contains some null values, which is not what I want.
Is there any method that can distinguish between a null JavaScript Object and a JavaScript Object that contains some null values?
Thanks
To determine whether the target reference contains a member with a null value, you’ll have to write your own function as none exist out of the box to do this for you. One simple approach would be:
Needless to say, this only goes one level deep, so if one of the members on
targetcontains another object with a null value, this will still return false. As an exmaple of usage:Will print out:
In contrast, the following will print out
false: