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

Andrea Giammarchi andrea.giammarchi at gmail.com
Wed Nov 7 09:30:41 PST 2012


that's a feature ... and if you do that either you know what you are doing
or you need to know what you are doing.
Shared objects are powerful, not a problem .. not the problem here, imho


On Wed, Nov 7, 2012 at 9:27 AM, Kevin Smith <khs4473 at gmail.com> wrote:

>
>> Any other reasons for why they are discouraged?
>>
>
> This footgun:
>
>     function MyClass() {
>
>       this.value = 1;  // OK
>       this.list.push(0);  // Modifying the list for every instance -
> probably not intended.
>     }
>
>     MyClass.prototype.value = 0;
>     MyClass.prototype.list = [];
>
> - Kevin
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121107/db1f58f6/attachment.html>


More information about the es-discuss mailing list