couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Metson <simonmet...@googlemail.com>
Subject Re: View to find someone in a list in a document
Date Thu, 03 Sep 2009 09:11:18 GMT
Hi,
	I'm not sure if there's a technical benefit of this syntax, but I  
think I prefer reading it... Any JS wizards out there like to comment?
Cheers
Simon

On 3 Sep 2009, at 09:53, Nils Breunese wrote:

> I even learned that using for (... in ...) is not safe for use with  
> arrays. I tend to use Array.forEach() [0] like this:
>
> ----
> function(doc) {
>  if (doc.users) {
>    doc.users.forEach(function(user) {
>      emit(user, doc);
>    });
>  }
> }
> ----
>
> I'm not very proficient in JavaScript, so maybe there is no real in  
> advantage in the realm of CouchDB.
>
> Nils Breunese.
>
> [0] https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference:Objects:Array:forEach

Mime
View raw message