On Jan 10, 2014, at 11:49 AM, Brendan Eich wrote:
> Axel Rauschmayer wrote:
>
>> * Built-in prototype methods are non-enumerable, as is property `length` of
>> arrays.
>
> Good, more consistency with existing objects.
>
>> * In ECMAScript 6, prototype methods created by classes are enumerable, the
>> prototype method `constructor` is non-enumerable (as it is by default in all
>> functions).
>
> This may be a mistake. Prototype methods defined in JS are enumerable up to
> ES5 unless you use Object.defineProperty. Prototype methods on builtins are
> not enumerable. Something has to give.
>
The ES6 class specification originally made prototype methods (we didn't have
static methods at the time) non-enumerable.
That was changed at the Sept 19, 2012 TC39 meeting
https://mail.mozilla.org/pipermail/es-discuss/2012-September/025231.html
> # Concise Method Definition, Revisited
>
> RW: Defaulting concise methods to non-enumerable is a mistake
>
> DH: Not sure about the decision to go non-enumerable. Users expect that
> things they create to be enumerable and things that the platform provides
> to be non-enumerable.
>
> LH: enumerability is not a real concept with any sort of meaning.
>
> EA: (reveals the broken-ness of the DOM)
>
> No longer arguable.
>
> **Conclusion/Resolution**
> Concise method definitions create [[Enumerable]]: true
I went along with the majority, although I don't really like it very much.
It's basically a question of whether class definitions follow the pattern of
pre-ES6 built-in or the pattern of pre-ES6 manually constructed
constructor/prototype pairs.
Early on we decided to follow the built-in pattern, but at that meeting we
changed it WRT enumerability of methods.
It comes down to this
class C extends Array {
foo() {}
}
let c = {foo() {}}
let assignedClass = Object.assign({ }, C.prototype);
let assignedObjLit = Object.assign({ }, c);
original class design:
typeof assignedClass.foo //Undefined
typeof assignedObjLit.foo //Undefined
current ES6 spec:
typeof assignedClass.foo //function
typeof assignedObjLit.foo //function
another plausible design:
typeof assignedClass.foo //Undefined
typeof assignedObjLit.foo //function
Allen_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss