The first thing that I had to deal with after loading Prototype was that I could no longer use
for (i in array) { ... }, to iterate through array elements without getting a bunch of extra junk.  So I rewrote my for loops to go from 0 to array.length - 1 instead.The next thing really confused me for hours. I wanted to encode a Javascript data structure as JSON, and
JSON.stringify([]) would inexplicably result in "\"[]\"".  But if I used the browser's Javascript console, JSON.stringify([]) would correctly result in "[]".  Finally, I came across a web page that identified Prototype as causing this problem by setting Array.prototype.toJSON, among other things, which also explained to me why Prototype was screwing up my for loops iterating through arrays.
 
No comments:
Post a Comment