This problem been there for couple years.
I am writing some plugins for a Forum engine called Discuz, I use a lot of Mootools for my own projects. When I plug Mootools into this forum Engine(discuz) things went crazy...
After I did some debugging last year, I found that the problem is that Mootools prototype a lot of core elements, including Array, And, on the other hand, this forum engine uses a lof of For(i in Array) Loop for 'array'. Which will certainly cause problem because
for(i in [1,2,3,4,5]) console.log(i); //0,1,2,3,4 the keys in this array
**WITH MOOTOOLS
for(i in [1,2,3,4,5]) console.log(i);
//OUTPUT 0,1,2,3,4,$family,$constructor,pop,push,reverse,shift,sort,splice.......
Last time i use a parser to change all for(i in array) loop to add an 'if item.hasOwnProperty()' to by pass those prototypes But i think this is a very bad work-around cause u know, cause more problems...new versions, bug up their codes...etc
I wonder if there is work around to slove this problem? without touching any of this forum engine's js code, and also use Mootools?
I know that using For(..in ) for Array is bad, but my question is i dont want to touch this forum engine's javascript codes, i just want a solution to over load the problem
for-instatement is highly discouraged to iterate over array objects, its purpose is to enumerate object properties, if you use simple sequential loops, you will have less problems (they are also faster thanfor-in). See also: stackoverflow.com/questions/500504/… stackoverflow.com/questions/3010840/…