On Jun 25, 10:36 am, Johan Compagner <[email protected]> wrote:
> Hi,
>
> in java you can use the instanceof check on null and that will return false.
> But in rhino this results in a undefined error.
>
> var str = "str"
> if (str instanceof String) // works
>
> but
>
> var str = null; // or just var str; so undefined..
>  if (str instanceof String) // doesnt works
>
> is this the spec? Or just a bug in rhino
>
> If i patch rhino:
>
> ScriptRuntime: *public* *static* *boolean* instanceOf(Object a, Object b,
> Context cx)
>
> i add the line:
>
> *
>
> if
> * (a == *null* || a == Undefined.*instance*) *return* *false*;
>
> right after the if(b) check. Then above code works and i dont have to add
> extra checks for null..
>
> johan

This is correct. See ECMA 262, section 11.8.6.

--N
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to