[OpenLayers-Dev] javascript keys vs counter

Christopher Schmidt crschmidt at metacarta.com
Mon Oct 15 13:12:22 EDT 2007


On Fri, Oct 12, 2007 at 12:17:54PM -0400, Christopher Schmidt wrote:
> On Fri, Oct 12, 2007 at 12:03:10PM -0400, Jacob Westfall wrote:
> > On Thu, 11 Oct 2007 11:24:48 -0400
> > Christopher Schmidt <crschmidt at metacarta.com> wrote:
> > > for (item in feats) {  }
> > > 
> > > will return 0, 1, 2, etc.
> > > 
> > > It's the keys, not the objects, which are returned.
> > > 
> > > However, in general, you should just use the for (i = 0; i <
> > > feats.length; i++) types -- there are resources on the web that you can
> > > read about why and how, I'm sure, I'm just not up to researching them at
> > > the moment :)
> > 
> > Hi,
> > 	I haven't been able to find the resources you mention about this issue.  Should I be searching for keys versus counters?  Thanks,
> 

Found http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ , which was
what I was thinking about. There are a ton of comments on it, which tell
a little about what I was thinking about. However, I think in general
"Not confusing arrays and objects" would be the right thing to think of
this as, and the posts I was thinking about are about other issues.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Dev mailing list