classes and enumerability

Andrea Giammarchi andrea.giammarchi at
Wed Dec 24 16:47:50 PST 2014

Out of curiosity, which accessor, being a runtime info that once trapped in
a static property looses its meaning, is commonly needed for JSON ?

I am just thinking about `Array` and the fact that thanks gosh the `length`
is not in. What kind of logic you have in mind?

// to fix the exception
// with ... a **non enumerable** method ;-)
class SomeCase {
  toJSON() {
    var o = Object.assign({}, this);
    o.accessor = this.accessor;
    return o;

case solved in few lines and yet another method, the `toJSON` one, that
nobody wants to show up anywhere in an enumerable way.

Best Regards

On Thu, Dec 25, 2014 at 1:17 AM, Caitlin Potter <caitpotter88 at>

> Supposing that methods were non-enumerable by default, would accessors be
> different, or also non-enumerable by default?
> In most cases, accessors would make sense to be enumerable, e.g. for JSON
> serialization, but that would be sort of inconsistent and confusing if the
> default were different from methods
> (Just thinking out loud)
> > On Dec 24, 2014, at 7:09 PM, Brendan Eich <brendan at> wrote:
> >
> > Brendan Eich wrote:
> >> There's a confounding variable: the pain of ES6s meta-object APIs, in
> all respects.
> >
> > I meant "ES5's" here, of course.
> >
> > Agree with Jeremy, laziness is a programmer virtue and a part of human
> nature. People are not bothering where they don't know better, or do
> perhaps know enough but don't have time and cause to take the trouble. The
> trouble is due to the non-default nature of non-enumerability. Arguing from
> that past default to (still-future for a little while!) ES6 class's
> prototype methods being non-enumerable is circular, if you ignore the
> foolish-consistency argument (which I think we should, but I"m not
> dismissing here -- just noting that it isn't enough to avoid circularity
> because of the ES5's-painful-to-use confounder).
> >
> > /be
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at
> >
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list