preventExtensions trap and its true/false protocol

Jeff Walden jwalden+es at MIT.EDU
Mon Apr 1 10:11:19 PDT 2013

On 04/01/2013 09:41 AM, Brandon Benvie wrote:
> That is, the error that will be thrown from Object.preventExtensions is only specified as a TypeError; different engines can (and often do) have different error messages, and different localizations will also have different messages. This is something a developer can't hope to mimic.

Note that this could also be construed as a feature, in certain cases.  The "dead object" proxy Mozilla has, previously mentioned here (can't find a link), has all its traps throw an error with a message saying "Dead object".  If the trap returns true/false, it's no longer possible for preventExtensions to say that the object in question is dead, not just can't be made non-extensible.

Now, whether this use case, and other cases we could conjure up with a little thought, actually motivate reserving the throw to the trap -- that's another matter.  I'm just saying there are some small tradeoffs both ways here.


More information about the es-discuss mailing list