getOwnPropertyDescriptor side effects

Boris Zbarsky bzbarsky at
Wed Jan 11 15:38:55 UTC 2017

On 1/11/17 6:43 AM, Isiah Meadows wrote:
> Not if it's (likely) throwing from the `new Error`.

It's not.  The "stack" property in V8 quacks like a value property for 
the most part, but the first access to it invokes some code that does 
the (lazy) stack string construction.  That process involves calling 
Error.prepareStackTrace if such a thing exists.

Specifically, as of today, see 
which is called from

The whole setup is basically designed to have things that look like data 
properties but actually involve executing code to compute the property 
value (and possibly executing code when the "value" property is set).

SpiderMonkey has similar things as well, though we've been getting rid 
of them as much as possible.  The obvious one that remains is .length on 
Array objects.  This allows Array objects to be non-exotic for practical 
purposes in terms of their engine representation, and hence not suffer 
the performance penalties exotic objects suffer.  In spec terms, of 
course, Array instances are just exotic objects.  In an ideal world, the 
implementation detail is just that and is not observable....


More information about the es-discuss mailing list