couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Wolff <awo...@gmail.com>
Subject Re: View to find someone in a list in a document
Date Thu, 03 Sep 2009 17:06:26 GMT
One more little thing: per spec, for...in enumerates the array keys as
strings.
A

On Thu, Sep 3, 2009 at 8:29 AM, Jesse Hallett <hallettj@gmail.com> wrote:

> 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
> browsers.
>
> On Sep 3, 2009 3:46 AM, "Jan Lehnardt" <jan@apache.org> 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
> Jan
> --
>
> > Cheers > Simon > > On 3 Sep 2009, at 09:53, Nils Breunese wrote: > >>
I
> even learned that u...
>

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