1

Is there a secure way of doing this?

I tried

typeof {};
typeof someJavaObject;

But in both cases I am getting 'object'. I think this behavior is expected since all java objects are ScriptableObject, am I right?

So, then, how do I figure out if a variable refers to a javascript object (or a Java one)?

4

1 回答 1

1

您可以使用someJavaObject instanceof java.lang.Object.

我会写一个函数,所以很清楚你在做什么:

function isJavaObject(obj) {
    return obj instanceof java.lang.Object;
}
于 2013-09-24T01:36:35.143 回答