On Wed, Nov 7, 2012 at 9:17 AM, Axel Rauschmayer <a...@rauschma.de> wrote:

> 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).
>

This is due to the override mistake <
http://wiki.ecmascript.org/doku.php?id=strawman:fixing_override_mistake>
and affects methods as well as non-methods, since both are often overridden
by assignment. The unpleasant conclusion is that, since the committee
failed to agree to fix this mistake, the unfortunate generalization of your
conclusion is one of

* "Method and non-method properties in a prototype are an anti-pattern",
which becomes "using prototypal inheritance is JS is an anti-pattern".
* "Overriding by assignment is an anti-pattern", in which case, both method
and non-method inherited properties are fine.

In any case, note that the same kludge <
http://code.google.com/p/google-caja/source/browse/trunk/src/com/google/caja/ses/repairES5.js#369>
"fixes" both.




>
> Any other reasons for why they are discouraged?
>
> Thanks!
>
> Axel
>
> --
> Dr. Axel Rauschmayer
> a...@rauschma.de
>
> home: rauschma.de
> twitter: twitter.com/rauschma
> blog: 2ality.com
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
    Cheers,
    --MarkM
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to