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

Russell Leggett russell.leggett at gmail.com
Wed Nov 7 09:28:46 PST 2012


On Wed, Nov 7, 2012 at 12:27 PM, 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 = [];
>

+1 beat me to it.


>
> - 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/8c8aab93/attachment.html>


More information about the es-discuss mailing list