Why are non-method properties in a prototype an anti-pattern?

Axel Rauschmayer axel at rauschma.de
Wed Nov 7 09:32:23 PST 2012

Right. Spec terminology tripped me up. In ECMA-262, all properties that are neither accessors nor internal properties are called data properties.

Hence, I should have written: non-method data properties (instead of non-method properties).

On Nov 7, 2012, at 18:26 , David Bruant <bruant.d at gmail.com> wrote:

> Le 07/11/2012 18:17, Axel Rauschmayer a écrit :
>> In theory, one can use prototype properties to provide default values for instance properties. In practice, that is not often useful, because the constructor normally creates all instance properties right away, assigning default values where necessary. And, with default parameter values in ES6 that is even easier to do.
>> As mentioned by Andrea in another thread, another argument against non-method prototype properties is that they prevent you from freezing the prototype (because that would make assigning to instance properties impossible).
> inherited properties can be accessors. That's how WebIDL works.
> I have no opinion as to whether inherited data properties are a good or bad idea, though.
> David

Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121107/98326929/attachment-0001.html>

More information about the es-discuss mailing list