couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesse Hallett <>
Subject Re: View to find someone in a list in a document
Date Thu, 03 Sep 2009 15:29:02 GMT
According to Crockford `for in` gives no guarantee that it will iterate over
array elements in order.  That is in addition to the problem that it will
also enumerate any attributes on `Array.prototype`.  So Crockford recommends
using `for` with an incrementing index variable instead.

In my opinion Array#forEach is a better option.  But it is a
Spidermonkey-specific feature, added as part of JavaScript 1.6.  It will
work fine in CouchDB views, but it will not be available in a lot of web

On Sep 3, 2009 3:46 AM, "Jan Lehnardt" <> wrote:

On 3 Sep 2009, at 11:11, Simon Metson wrote: > Hi, >        I'm not sure if
there's a technical be...
to get for(... in .. ) right you need to add:

a hasOwnProperty() call to account for prototypical inheritance behaviour.

In addition forEach and a closure can be optimised behind the scenes better.


> Cheers > Simon > > On 3 Sep 2009, at 09:53, Nils Breunese wrote: > >>
even learned that u...

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message