Hello, We have a problem that is related to what is described on http://prototypejs.org/api/array . We have added prototype.js into our product and just adding it breaks existing code which relies on associative arrays.
We can change some of the arrays to follow the prototype syntax. However, I m wondering whether there is a work around to this problem especially because there is customer code that we can't change. Also with porotype our application won't work in MashUps.
I am sure this is not the first time some has encountered this problem. This is really a blocker for us right now. Any help or input is highly appreciated.
Perhaps you could show us a small example of the type of thing that is breaking on your page? Please keep the example small, and be sure to use UBB code tags when posting code.
I can pretty confirm that this has always been a problem. Maybe its fixed in 1.6 but prototype changes the default behavior of arrays globally when added to a page. It's a PITA. And one more reason why I use JQuery instead of Prototype.
Gregg, what specifically have you seen? I know Prototype adds behavior to Array, but what core behavior no longer works? We use both jQuery and Prototype at my day job and this isn't something we've banged our heads on (yet).
As for code you do not have control over (as in, you don't write it, you don't maintain it, and you can't hack its source), well, if they misuse Array and for...in, have the author behave! Or failing that, change libs. Prototype won't change a perfectly legitimate extension just because other developers take an erroneous road and refuse to straighten things up when alerted to the issue :-/
The documentation for Prototype's extensions does explain the issue with code examples. Feel free to ask any further question on the issue here.
Originally posted by Christophe Porteneuve: In your code, avoid misusing Array as an associative array (or hash).
Indeed, this is a pattern propagated by many examples on the web, and by many books. For what reason, I do not know.
Perhaps it's the fact that the general de-referencing operator and the indexing operator are both the square brackets, leading people to believe that somehow an Array is necessary to reference object properties using the  operator.