From kfm-devel Sat Jan 11 15:28:35 2003 From: Harri Porten Date: Sat, 11 Jan 2003 15:28:35 +0000 To: kfm-devel Subject: Re: kjs: about if(undefvar)... X-MARC-Message: https://marc.info/?l=kfm-devel&m=104229900401083 On Sat, 11 Jan 2003, Koos Vriezen wrote: > eval("if (xxx) alert('defined'); else alert('undefined');"); > has changed. It now throws an exception (used to be 'false' iirc). Is that > correct behaviour? Yes. The behaviour is correct as I see it. It's a consequence of fixing the Windows object after David and me believe to finally understand why if (xxx) var xxx = 0; works. The difference to your case: the variable *is* declared. Order of declaration doesn't matter. > (I need to change the js code in netscape.javascript.JSObject if so) > How about the following check: if (window.xxx) { .... } The direct check can be made without risking an exception. Harri.