for always work I meant as long as the object is not sealed/frozen as discussed a while ago
On Tue, May 21, 2013 at 9:43 AM, Andrea Giammarchi < andrea.giammar...@gmail.com> wrote: > On Tue, May 21, 2013 at 12:56 AM, Brendan Eich <bren...@mozilla.com>wrote: > >> Andrea Giammarchi wrote: >> >>> can I also suggest to analyze, if there's still any doubt left on a >>> method VS a property yet, this piece of code if not highlighted before? >>> >> >> I do not understand what you mean here. >> >> > I mean that JSON, as part of the specs, needs to consider that "magic" > property case, resulting into an `instanceof Object`, with an enumerable > property that will show up in a `for/in` loop but it's not able to mutate > the object. > > ``` > var obj = JSON.parse('{"__proto__":[]}'); > alert(obj instanceof Array); // false > alert(obj["__proto__"] instanceof Array); // true > obj["__proto__"] = obj["__proto__"]; > // or > for (var key in obj) { > obj[key] = obj[key]; > // could be a generic > // clone operation > } > alert(obj instanceof Array); // false > alert(obj instanceof Object); // true > ``` > > Above kind of object is "not perfectly described in current specs" and is > different from any other where the `__proto__` is the inherited and not own > property. > > This is what developers should be aware of, that `__proto__` might not be > what they think is while `Object.setPrototypeOf(obj, proto):obj` will > always work as expected, as well as `Object.getPrototypeOf(obj):proto` > > All I am saying is that I understood reasons `__proto__` is there but I > hope there won't be any step backward about `Object.setPrototypeOf` > > All the best and looking forward to read the notes. > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss