From: Thomas 'PointedEars' Lahn on
Garrett Smith wrote:

> A bit of advice here regarding the `in` operator [with host objects].
> In a nutshell: Avoid doing that.
> [...]
> It is generally safer to use the typeof operator and compare the result
> against undefined.

I believe I have been telling that for years. Well, better late than never.
The "catchall" probably makes it to a footnote in the ECMAScript Support
Matrix, though.


PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
From: Garrett Smith on
David Mark wrote:
> Garrett Smith wrote:
>> David Mark wrote:
>>> Garrett Smith wrote:

[...]
>> You did not explain the reasons for why it doesn't work. My explanation
>> explains how catchalls work shows where they affect the `in` operator.
>
> It doesn't matter if I explained them or not. Like the "revelation"
> about properties of ActiveX objects, and various other things over the
> years, I ultimately turned out to be right (and you turned out to be
> wrong). That's my point. ;)

Would a catchall be implemented with a method lookup, as:

if("createElement" in document) ;

An implementation wouldn't have a good reason to use a catchall for that.

A catchall would be used to try to get a value from an object, such as
with the indexed getters or name getters from collections such as
navigator.plugins.
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
First  |  Prev  | 
Pages: 1 2
Prev: singleton
Next: There I fixed it?