Is it spec-compliant to forbid setPrototypeOf(Object.prototype, foo)?
tj.crowder at farsightsoftware.com
Thu Feb 2 12:31:13 UTC 2017
On Thu, Feb 2, 2017 at 12:19 PM, Michał Wadas <michalwadas at gmail.com> wrote:
> Right now this code:
> Object.setPrototypeOf(Object.prototype, Object.create(null))
> throws in both Chrome and Firefox. I couldn't find any mention of special
> [[SetPrototypeOf]] of %ObjectPrototype%, did I miss something?
Yes. :-) You missed that `Object.prototype` is an immutable prototype
...which does indeed have a special [[SetPrototypeOf]] which (indirectly)
returns false if you try to change the [[Prototype].
`Object.setPrototypeOf` throws when [[SetPrototypeOf]] returns false:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss