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 <halle...@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" <j...@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...
>

Reply via email to