The precise meaning of "For each named own enumerable property name P of O"

Brendan Eich brendan at mozilla.com
Sat Oct 10 18:33:28 PDT 2009


On Oct 10, 2009, at 1:09 PM, Brendan Eich wrote:

> In either case shadowing must be handled. Implementations using the  
> "snapshot each object while traversing once" approach may see  
> different shadowing effects than implementations that snapshot the  
> whole chain up front and traverse again during the loop:
>
>    function f(){}
>    o = new f;
>    o.p = 1, o.q = 2;
>    f.prototype.r = 3;
>    a = [];
>    for (i in o) {
>        o.r = 4;
>        a.push(i);
>    }
>    alert('[' + a.join(', ') + ']');
>
> (available at http://pastebin.mozilla.org/675804). This gives  
> different results in different browsers although the result "[p, q]"  
> shows what looks to me like a bug in Mozilla's SpiderMonkey  
> implementation (I didn't test Rhino) where the late addition of o.r  
> can shadow the prototype property. I'll file it.

Filed at

https://bugzilla.mozilla.org/show_bug.cgi?id=521617

/be


More information about the es-discuss mailing list