My ECMAScript 7 wishlist
Andrea Giammarchi
andrea.giammarchi at gmail.com
Sun Jun 15 14:24:16 PDT 2014
> Because NoSuchProperty is meant to be inserted just before
Object.prototype
I miss this constrain, wouldn't have bothered with the loop otherwise.
Regards
On Sun, Jun 15, 2014 at 11:27 AM, Brendan Eich <brendan at mozilla.org> wrote:
> Andrea Giammarchi wrote:
>
>> In such case the only concern would be why `Object.prototype` is
>> considered but not inherited properties too.
>>
>
> Because NoSuchProperty is meant to be inserted just before
> Object.prototype, avoiding that loop.
>
> What's more, the loop is unnecessary:
>
>
> var NoSuchProperty = Proxy({}, {
> get: function(target, name, receiver) {
> while (target = Object.getPrototypeOf(target)) {
> if (name in target) {
> return Reflect.get(target, name, receiver);
> }
> }
> throw new TypeError(name + " is not a defined property");
> }
> });
>
>
> If NoSuchProperty is inserted just before Object.prototype on a chain of
> ordinary objects, its get handler won't be invoked until no such property
> is indeed found along the path from the original target to NoSuchProperty.
> Therefore all iterations but the last (where target is Object.prototype)
> are redundant.
>
> /be
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140615/d74ded52/attachment.html>
More information about the es-discuss
mailing list