My ECMAScript 7 wishlist

Brendan Eich brendan at mozilla.org
Thu Jun 5 18:25:05 PDT 2014


LOL - as if O.p has getters!

Thanks, this is more general in case of insanity.

/be

> On Jun 5, 2014, at 6:09 PM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
> 
> 
>> On Jun 5, 2014, at 5:52 PM, Brendan Eich <brendan at mozilla.org> wrote:
>> 
>> Rick Waldron wrote:
>>> 
>>>> * `Object.preventUndeclaredGet()` - change an object's behavior to throw an error if you try to read from a property that doesn't exist (instead of returning `undefine`).
>>> 
>>> This can be achieved with Proxy right, or is that too cumbersome?
>> 
>> js> var NoSuchProperty = Proxy({}, {
>>   has: function(target, name) { return true; },
>>   get: function(target, name, receiver) {
>>     if (name in Object.prototype) {
>>       return Object.prototype[name];
>>     }
>>     throw new TypeError(name + " is not a defined property");
>>   }
> 
> need to make sure accessor methods use the right this value:
> 
>     get: function (target, name, receiver) {
>            if (name in Object.prototype) return Reflect.get(Object.prototype, name, receiver);
>            throw new TypeError(name + “ is not a defined property”);
>      }
>> });
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140605/40947c70/attachment.html>


More information about the es-discuss mailing list