Hey there!

Renaud a écrit :
> Is there a way to create regular javascript arrays when using
> Prototype?

Nope.  Since the prototype is extended, there's no way to create an
array w/o those.  However, you can create an object that acts as an
array (a container with properties, that is), and pass it off to
functions using for/in loops:

var myContainer = { '0': 'foo', '1': 'bar' };

This gets tricky for dynamic addition of properties though (since using
a length property in there would make the length property appear in the
for/in loop...).

> sites but it already uses lots of other pieces of javascript that use
> the for (x in myArray)... construction. When using that kind of loop

Well, for/in is not exactly intended for array looping.  It's a property
iteration mechanism.  Codes that use it for array looping are relying on
the fact that arrays are not extended in any way, which isn't very
clean, because prototype-extension-based frameworks are gaining major
foothold in the web client-side world.

So your best bet /in the long run/ would be to avoid such code (if you
wrote it, switch to numerical loops; if you didn't, request a fix from
the original coders; if they won't respond, switch to another lib!).

> I'm not sure whether this is a bug or something I'm doing wrong..

The for/in code for array iteration does something inadequate, inasmuch
as this doesn't play well with "programming in the large" (in this
context, playing nicely with large amounts of external code and possible
object extensions).

'HTH.

-- 
Christophe Porteneuve aka TDD
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---

Reply via email to