Why we need to clean up __proto__
Mark S. Miller
erights at google.com
Wed Dec 28 18:11:05 PST 2011
On Wed, Dec 28, 2011 at 5:59 PM, John J Barton
<johnjbarton at johnjbarton.com>wrote:
> On Wed, Dec 28, 2011 at 1:15 PM, Axel Rauschmayer <axel at rauschma.de>wrote:
>> On Dec 28, 2011, at 17:13 , John J Barton wrote:
>> Doesn't Object.keys() solve this problem?
>> For getting elements, yes. For setting, the problem with the illegal own
>> property name "__proto__" remains.
> Doesn't this same problem face any property of an object-as-dictionary
> which is also a property needed for the dictionary to work properly? So
> fixing __proto__ is not important, it's inadequate?
Good uses of objects-as-stringmaps use the objects *only* as stringmaps.
Aside from the use of "hasOwnProperty" as an instance method in Crock's
original example, which he elsewhere shows how to correct, Crock's
"registry" is used correctly. Together with the proposed __proto__ as
accessor behavior, Crock's code would actually be correct (though I'd still
advise using an abstraction like StringMap that can encapsulate such
hazards and present a simple interface).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss