[webkit-dev] [JavaScriptCore] Is property attribute ReadOnly working as intended here?
Gavin Barraclough
barraclough at apple.com
Mon Dec 2 11:29:40 PST 2013
On Dec 2, 2013, at 10:53 AM, Geoffrey Garen <ggaren at apple.com> wrote:
> Hi Alexei.
>
>> To my knowledge, an object's prototype is consulted when a property is not found on the object itself. Any new property is written to the object, never its prototype.
>
> That’s not quite right. The prototype chain is consulted when assigning a new property, if the prototype has a property of that name.
Actually that statement is true – any newly created property will only ever be on the object, never its prototype.
>> So I was expecting to add the "ctor" property on "newClassObj" directly and shadow the prototype's read-only "ctor", but it seems that either the property is set on the object's prototype (and the ReadOnly attribute makes it a no-op) or the ReadOnly attribute contaminates the object itself.
The prototype chain is consulted, and presence of a read only property will cause assignment to fail. Default is to fail silently, but if you use strict mode you’ll get an exception.
If you want to create a shadowing property on the object you can do so via Object.defineProperty.
cheers,
G.
> Geoff
> _______________________________________________
> webkit-dev mailing list
> webkit-dev at lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
More information about the webkit-dev
mailing list