Object.defineProperty with { get: undefined, set: undefined }

Mark S. Miller erights at google.com
Mon Aug 3 19:04:17 PDT 2009


On Mon, Aug 3, 2009 at 6:39 PM, Allen Wirfs-Brock <
Allen.Wirfs-Brock at microsoft.com> wrote:

> Good one, I surprised that this has never come up before. I don't think
> there is anything intentional about the current design, it just fell out.
>
> Such a property would have pretty much the same effect as
> Object.defineProperty(obj, propname, { value: undefined})
>
> which creates a readonly, nonenumerable, nonconfigurable property whose
> value is undefined. There isn't much (if any, I need to look a litter
> deeper) real behavioral difference between such a data property and the
> equivalent accessor property except for what can be observed using
> Object.getOwnPropertyDescriptor.
>
> I suppose we could put more conditions into [[DefineOwnProperty]] to reject
> accessors where both [[Get]] and [[Put]] are undefined. Do you think this is
> a significant issue?  Is it an error that is likely to be made?
>  [[DefineOwnPropoerty]] is already fairly complicated so unless there is
> some real hazard to allowing such properties I'm inclined to leave it as is.
>

I vote to leave it as is. Even if this setting doesn't make particular sense
by itself, to prohibit it creates a special case. Symmetry and lack of
hazard suggests allowing it. And given the last date...

-- 
   Cheers,
   --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20090803/bdf65af7/attachment.html>


More information about the es-discuss mailing list