Object.getOwnPropertyDescriptors(O) ? // plural

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Mar 4 10:18:49 PST 2014

this boilerplate is error prone and prolix plus it cannot be optimized in
core so it's also very slow.

With the introduction of classes, Symbols, and all ES6 new entries, I feel
like the `for(var key in object)` loop is dead but developers have no way
to clone objects in the right way and in one shot possibly
optimized/optimizable in core.

I understand it's very late but I wonder, with Rick help, if a "brutal"
copy and paste of a very simple spec that feels natural as complement of
the singular `Object.getOwnPropertyDescriptor(O, k)` would be considered
... I certainly don't want waste Rick time with this, neither yours, of

So, in case ES6 is not an option, I wonder if we could have a slot in ES7
so that the polyfill could be adopted and developers life made easier.

I really hope I didn't need in ES6 to write this:

var shallowCopy = Object.create(
  ).reduce(function (descriptors, name) {
    descriptors[name] = Object.getOwnPropertyDescriptor(
      originalObject, name
    return descriptors;
  }, {})

Thanks in advance for any outcome.

On Tue, Mar 4, 2014 at 10:03 AM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote:

> On Mar 4, 2014, at 9:34 AM, Rick Waldron wrote:
> On Tue, Mar 4, 2014 at 12:30 PM, Andrea Giammarchi <
> andrea.giammarchi at gmail.com> wrote:
>>  Apparently this triggered an @rwaldron which seems to be super-effective
>> In agenda for April's meeting.
> Yep: https://github.com/tc39/agendas/blob/master/2014/04.md
> Going to try, but it's so late in the game that I really can't promise
> anything--I think it's simple enough that we can get away with it. I will
> write up a proposed normative spec (likely based on Andrea's work) before I
> present, I've found that's a pretty powerful way to make a case for late
> additions ;)
> I like this cloning idiom, but I don't see why we would consider this for
> ES6, it isn't something that is critical or can't be implemented via ES
> code.  It would be much more appropriate to queue it up for the 2015 train.
> ES6: let's wrap this sucker up!
> Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140304/ed5fb0ab/attachment.html>

More information about the es-discuss mailing list