Subj : Re: Confused about enumerating To : netscape.public.mozilla.jseng From : Brian Genisio Date : Wed Feb 18 2004 10:20 am Brendan Eich wrote: > See JSCLASS_NEW_ENUMERATE and read jspubtd.h for a different approach > that does not require you to set properties at the start of the > enumeration. However, it's always good to make what for..in discloses > match what can be accessed on a "get by get" basis, if you know the > ids. IOW, all enumerable properties should appear to be properties, > even if they're reflected from private data using some kind of shared > (JSPROP_SHARED) prototype getter, e.g. > > /be Wonderful... using JSCLASS_NEW_ENUMERATE works like a charm... except when I return a property name that already exists. See, the object is much like an array, so the length property is defined with the object, so myCollection.length is retrieved correctly. If, I enumerate the values of myCollection, the first thing I want to return is the length... so I do the following: JS_ValueToId(cx, STRING_TO_JSVAL(JS_InternString(cx, "length")), idp); In this case, the for..in loop gets an empty string. If instead, I set the jsid with a slightly different spelling: JS_ValueToId(cx, STRING_TO_JSVAL(JS_InternString(cx, "Length")), idp); It works fine. Any ideas to why this is? Brian .