Why are non-method properties in a prototype an anti-pattern?
andrea.giammarchi at gmail.com
Wed Nov 7 10:17:33 PST 2012
also, properties can be defined as getters and setters so that you might
want to share them in the same scope/context the rest of the prototype is
defined and not later on inside the constructor.
Yes, there are work around for this but again, if that Object.freeze
problem is solved, there is no reason to avoid properties in the prototype,
On Wed, Nov 7, 2012 at 10:02 AM, Andrea Giammarchi <
andrea.giammarchi at gmail.com> wrote:
> same would be for data methods
> On Wed, Nov 7, 2012 at 9:52 AM, John J Barton <johnjbarton at johnjbarton.com
> > wrote:
>> On Wed, Nov 7, 2012 at 9:17 AM, Axel Rauschmayer <axel at rauschma.de>wrote:
>>> In theory, one can use prototype properties to provide default values
>>> for instance properties.
>> In practice instances are free to write on these values in addition to
>> using them as defaults. Then suddenly the 'default' is changed for other
>> instances. It is then you realize that the theory is not a very good one.
>> es-discuss mailing list
>> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss