So to sum up, then, and circle back to Francisco Tolmasky's original question:
* For ordinary objects, `Object.getOwnPropertyDescriptor` shouldn't have side-effects because none of the ordinary operations it uses has side effects. * For exotic objects, it may well have side effects as a result of an exotic version of [[GetOwnProperty]]; for instance, Adam Klein's `Proxy` example. * `Error` objects are specified as ordinary objects. * V8's `Error` object has a `stack` property that claims to be a value property (not an accessor). * V8's `Error` object is a exotic object, it has exotic behavior for [[GetOwnProperty]], because it triggers filling in the string for the captured stack trace if you call it for `stack` (it has to, in order to provide the `value` property of the descriptor, since `stack` claims to be a value property). * This aspect of V8's `Error` could be in-spec by making `stack` an accessor instead (or by building the string earlier, but it's deferred for performance reasons). Is that a reasonable summary? Additionally, I believe the only exotic object defined by the specification that has a [[GetOwnProperty]] with potential side effects is `Proxy`. Provided that's all correct, Francisco's answer is: Per spec, you can't rely on `Object.getOwnPropertyDescriptor` not having side effects unless you can guarantee you're not dealing with a `Proxy`. Per spec, you could for non-`Proxy` objects defined by the specification, but that's not currently the case with V8 (at least). And there's always the possibility of host objects having exotic [[GetOwnProperty]] behavior. -- T.J. _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

