My ECMAScript 7 wishlist

Nicholas C. Zakas standards at nczconsulting.com
Fri Jun 6 09:16:21 PDT 2014


On 6/6/2014 8:38 AM, Mark S. Miller wrote:
>
>     But the concern Nicholas raises doesn't seem to have this
>     property. Reading a property that doesn't exist doesn't carry a
>     security risk, does it? Object.preventUndeclaredGet doesn't really
>     protect against anything like ES5 methods did.
>
>
> That's true, but misses the point I was trying to make. For normal ES 
> objects, it is already part of their API contract with their clients 
> that the clients can do feature testing to detect the presence or 
> absence of a method. The most common way to do such feature testing is 
> to get the property and see if it is falsy. (Variations include, 
> testing for undefined, testing for undefined or null, and testing if 
> its typeof is "function".) It's fine if the provider of an abstraction 
> does not wish to support this pattern. But it is not ok for one client 
> of an object which does support it to prevent that object's other 
> clients from successfully using feature detection.

Sorry I was sleeping while most of this conversation was happening. :)

I understand the point about feature detection, it would suck if some 
random code did Object.preventUndeclaredGet() on an object you own and 
were using feature detection on. I still wish for some way to do this 
other than through proxies, but I agree that it would be nice for just 
the object provider to be able to set this behavior.

-- 
___________________________
Nicholas C. Zakas
http://www.nczonline.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140606/8539b71b/attachment.html>


More information about the es-discuss mailing list