On Sun, Jan 18, 2009 at 1:58 PM, Andreas Junghans <
andreas.jungh...@stz-ida.de> wrote:
> > qooxdoo adds these functions to the Array prototype to provide a
> > consistent interface between browsers. Although it seems to work to
> > iterate an Array use for/in, it's not technically legal.
>
> Sorry, I disagree. It's perfectly legal to iterate over an array with
> for ... in. In fact, it can be very useful to do so if you're working
> with sparse arrays (where only a few indices are ever assigned a
> value). Please keep in mind that there's not a lot that separates a
> JavaScript Array instance from any arbitrary object (which is always
> an associative array in JavaScript):
>
Ok, you're right. Since all of my javascript programming these days is with
qooxdoo, I sometimes forget what's qooxdooish and what's really javascript.
Most of the time they jive. Here they don't.
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.) Given that IE does behave
differently than Firefox in this area, I agree with you that qoxodoo should
not add methods to the Array prototype. I believe that you and I both argued
that long ago. At this point, however, it would be a huge
backwards-compatibility hit to remove them. I would recommend that they be
removed in 0.9 with migration scripts to correct the array method usage to
static function usage.
For qooxdoo use right now, if one wants to use for/in, the following usage
model might be appropriate:
var a = new Array();
var x = new Array();
a[23] = 42;
for (var i in a)
{
if (! isNaN(parseInt(i)))
{
x.push(i + ": " + a[i]);
}
}
alert(x.join('\n'));
I've tested that this works properly in both Firefox and IE.
Cheers,
Derrell
------------------------------------------------------------------------------
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