Hey Sapna,
Oh, that's quite simple. In your code, avoid misusing
as an associative array (or hash). JavaScript did not intend it for this purpose, but for integer-indexation storage.
If you need associative arrays / hashes, use what JavaScript gives you:
plain objects. In JS, every object acts as an associative array. If you want syntactic sugar over it and a few nifty tricks, since you appear to be using Prototype, use its
type (warning: version 1.6 now requires explicit get/set access, much like
Java, in order to prevent accidental collisions between the storage of the hash and the numerous mixed-in methods).
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.
'HTH