Fx4 (SpiderMonkey)'s behaviour is valid in ES5 spec. Assignment to Object Property Reference (obj.prop = "own") call [[Put]] internal method. [[Put]] checks "this value can be put" by calling [[CanPut]]. [[CanPut]] checks inherited PropertyDescriptor in 8.12.4-5, and in this case, variable "inhrerited" is PropertyDescriptor of Ctor.prototype.prop. Because inherited.[[Writable]] is false, [[CanPut]] returns false (8.12.4-8-b) and [[Put]] rejects this assignment.
thanks. On Sat, Mar 12, 2011 at 11:19 PM, michalr <michal.raczkow...@gmail.com> wrote: > Hello, > I discovered that the following ES5 code evaluates differently in FF4 > than Chrome and Safari. > > > function Ctor() {}; > Object.defineProperty(Ctor.prototype, "prop", { > value: "prototype", > writable: false > }); > > var obj = new Ctor(); > obj.prop = "own"; > alert(obj.prop + ", " + obj.hasOwnProperty("prop")); > > > Chrome and Safari gives: "own, true". > FF4 gives: "prototype, false". > > Could anybody explain why? > > greetings > Michal > > -- > To view archived discussions from the original JSMentors Mailman list: > http://www.mail-archive.com/jsmentors@jsmentors.com/ > > To search via a non-Google archive, visit here: > http://www.mail-archive.com/jsmentors@googlegroups.com/ > > To unsubscribe from this group, send email to > jsmentors+unsubscr...@googlegroups.com > -- To view archived discussions from the original JSMentors Mailman list: http://www.mail-archive.com/jsmentors@jsmentors.com/ To search via a non-Google archive, visit here: http://www.mail-archive.com/jsmentors@googlegroups.com/ To unsubscribe from this group, send email to jsmentors+unsubscr...@googlegroups.com