Path: csiph.com!usenet.pasdenom.info!news.albasani.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <7595870.kvP59otsHy@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 13 Apr 2013 21:31:16 +0200 User-Agent: KNode/4.8.5 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <87fvyv1r7q.fsf@gmail.com> <7902669.URqpOMyR7R@PointedEars.de> <2061545.QaVc4i2NtW@PointedEars.de> <1693880.XzSgBGLykG@PointedEars.de> MIME-Version: 1.0 Lines: 53 NNTP-Posting-Date: 13 Apr 2013 21:31:42 CEST NNTP-Posting-Host: 2775198d.newsspool3.arcor-online.net X-Trace: DXC=2j2R;V@d=XS5TOT9_N5i]gf^N W dniu 2013-04-13 13:26, Thomas 'PointedEars' Lahn pisze: >> Cezary Tomczyk wrote: >>> W dniu 2013-04-13 11:45, Thomas 'PointedEars' Lahn pisze: >>>> Cezary Tomczyk wrote: >>>>> W dniu 2013-04-13 10:29, Thomas 'PointedEars' Lahn pisze: >>>>>> Mikael Andersson wrote: >>>>> [...] >>>>>>>> if (window.XMLHttpRequest) { >>>>>> >>>>>> Insufficient and error-prone, see isHostMethod(). >>>>> [...] >>>>> >>>>> Just our of curiosity: in which environment / scenario this will not >>>>> be properly evaluated? >>>> >>>> Where “XMLHttpRequest” is not a property of the object referred to by >>>> “window”, but of another object in the scope chain. >>> >>> Even then isHostMethod will return true, >> >> No, it will return “false”. The point is _not_ that you should call > > Can you provide me an example of when this may occur? No, you just need to read more carefully. Hopefully a *working* implementation of isHostMethod() will return a false-value if the property in question does not exist. >> isHostMethod(window, "XMLHttpRequest") >> >> or >> >> jsx.object.isHostMethod(jsx.global, "window", "XMLHttpRequest") >> >> instead – that would be equally wrong –, but that isHostMethod() >> implements the *algorithm* to detect host methods *safely*, without >> implicit type conversion. > > I know both of methods, but sometimes simple statement "if > (window.XMLHttpRequest)" just do the job and I never had any problems > with that. You were asking about possible scenarios; I have provided you with them. You should not think that “it works” justifies approaches that are objectively unwise at best. See also: Argumentum ad crumenam. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.