Hi, On Jan 5, 1:02 pm, Jake <jgarfi...@earthlink.net> wrote: > I have learned the problem is not with iterationg, but if I do > something like this: > > var markers = transport.responseText.evalJSON(true) > thisObj.adjustResultsForMovement.bind(thisObj, markers)(); > > If markers is an empty array [], then whenadjustResultsForMovement is > called, prototype changes the markers array and adds all of the > prototype functions. It doesn't do this when markers has elements. > > Is there a way I can stop it from adding all of these functions?
No, but there's also no reason to. `for..in` does *not* loop through the indexes of an array; it loops through the property names of an object (see the JavaScript spec*) leaving out those marked as "non- enumerable". Using `for..in` to loop through arrays is incorrect, regardless of whether you're using Prototype. It *seems* to work in bland environments because all of the default properties of the Array type other than its indexes are marked non-enumerable, but it breaks as soon as you do something like this (which is perfectly valid when using a dynamic language like JavaScript): var a = []; a.baggage = "Something info I want to carry with the array, alongside its elements"; ...because `baggage` then shows up in the loop. Your best bet is is to use a normal everyday `for` loop. More here: http://proto-scripty.wikidot.com/prototype:tip-looping-through-arrays * Right now linking to the latest JavaScript spec is a real pain; grab the latest tc39-xxxx-xxx.pdf file from here: http://www.ecma-international.org/publications/files/drafts/ HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / com www.crowdersoftware.com
-- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.