Subj : Re: Another JS question To : netscape.public.mozilla.jseng From : Issac Goldstand Date : Thu May 06 2004 08:08 pm "Brendan Eich" wrote in message news:4097D27D.1050600@meer.net... > > > > I'm going to take a leap here and say "no". Whether you index an object > > using foo.bar or foo["bar"], javascript doesn't differentiate between > > the two. (At least, I haven't yet found anything in the spec to say > > otherwise.) > > I'm not sure that was Isaac's question. But the point remains that if > you are passed an Array that has had only named properties added to it, > you should enumerate it using for..in, not by indexing from 0 to length, > because length will be 0. > I must be missing something here - for..in is JS syntax, right? How does that help me in C? The only thing I can think of (thanks to looking closely at Sterling's APIREF) is: JSIDArray *jids=JS_Enumerate(cx,obj); for (int i=0;i< jids->length;i++) { if (JS_IdToValue(cx,jids->vector[i],&rval)) { ... examine and process rval ... } else { ... handle unexpected "holes" in JSIDArray } } Or am I totally barking up the wrong tree? Issac .