<div dir="ltr">Thank you very much. I've found both your hints about "use strict" and Object.defineProperty very useful.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Dec 2, 2013 at 9:29 PM, Gavin Barraclough <span dir="ltr"><<a href="mailto:barraclough@apple.com" target="_blank">barraclough@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><br>
On Dec 2, 2013, at 10:53 AM, Geoffrey Garen <<a href="mailto:ggaren@apple.com">ggaren@apple.com</a>> wrote:<br>
<br>
> Hi Alexei.<br>
><br>
>> 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.<br>
><br>
> That’s not quite right. The prototype chain is consulted when assigning a new property, if the prototype has a property of that name.<br>
<br>
</div></div>Actually that statement is true – any newly created property will only ever be on the object, never its prototype.<br>
<div class="im"><br>
>> 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.<br>
<br>
</div>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.<br>
<br>
If you want to create a shadowing property on the object you can do so via Object.defineProperty.<br>
<br>
cheers,<br>
G.<br>
<br>
<br>
> Geoff<br>
> _______________________________________________<br>
> webkit-dev mailing list<br>
> <a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
> <a href="https://lists.webkit.org/mailman/listinfo/webkit-dev" target="_blank">https://lists.webkit.org/mailman/listinfo/webkit-dev</a><br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Best regards<br>Alexei Sholik
</div>