Andreas Junghans schrieb:
> Hi Derrell,
>
> Am 18.01.2009 um 20:42 schrieb Derrell Lipman:
>
>   
>> It's also perfectly legal, however, as with any object, to add  
>> additional methods to Array's prototype, and I don't believe that  
>> the spec says whether these new methods should or shouldn't be  
>> enumerated with for/in when using an array. (I would argue that they  
>> shouldn't be, and that it's a bug in IE that they are, but that's a  
>> separate issue.)
>>     
>
> I'm not sure whether these methods should be enumerated or not.
>   
The behaviour is absolutely correct. These methods must be enumerated. 
The buildin methods attached to the prototype are not enumerated but if 
you manually attach other metheds (as we do in IE) they must be 
enumerated. To avoid the enumeration of methods defined in the prototype 
you can use the "hasOwnProperty" method:

for (variable in object) {
    if (object.hasOwnProperty(variable)) {
        statements
    }
}

This is how Douglas Crockford advocates iterating over the keys of a 
Map. IMHO the same is true for sparse arrays. You can use exactly the 
same loop and the methods defined in the prototype are not enumerated.

Best Fabian


-- 
Fabian Jakobs
JavaScript Framework Developer

1&1 Internet AG
Brauerstraße 48
76135 Karlsruhe

Amtsgericht Montabaur HRB 6484

Vorstand: Henning Ahlert, Ralph Dommermuth, Matthias Ehrlich, Thomas 
Gottschlich, Matthias Greve, Robert Hoffmann, Markus Huhn, Oliver Mauss, Achim 
Weiss
Aufsichtsratsvorsitzender: Michael Scheeren


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to