Nuking misleading properties in `Object.getOwnPropertyDescriptor`

Herby Vojčík herby at
Thu Mar 14 01:20:37 PDT 2013

Tom Van Cutsem wrote:
> [+Allen]
> 2013/3/13 Nathan Wall <nathan.wall at <mailto:nathan.wall at>>
>     However, as a matter of principle, my argument is that
>     `Object.getOwnPropertyDescriptor` should, at the bare minimum,
>     return a descriptor that can be known to work in
>     `Object.defineProperty`.  If `Object.defineProperty` doesn't accept
>     it, then you `getOwnPropertyDescriptor` didn't really give me a
>     valid descriptor.
>     I think that this behavior (1) limits the creativity of developers
>     to define properties like `Object.prototype.get`, (2) is a potential
>     stumbling block, (3) has no real benefit -- really, there's not
>     anything positive about this behavior, and (4) forces developers who
>     want to support `Object.prototype.get` to add an extra layer of
>     cleaning before using `defineProperty`.
> While the monkey-patching of Object.prototype ("don't do that!") is
> still the culprit, I agree that it would have been better if
> defineProperty looked only at "own" properties of the descriptor. I
No, there are legitimate uses of Object.create(descriptorTemplate) with 

> almost always think of descriptors as "records" rather than "objects".
> Similarly, perhaps Object.getOwnPropertyDescriptor should have returned
> descriptors whose [[prototype]] was null.


More information about the es-discuss mailing list