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

Axel Rauschmayer axel at rauschma.de
Wed Nov 7 09:30:05 PST 2012


Nice one!

On Nov 7, 2012, at 18:27 , 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

-- 
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/909e205d/attachment-0001.html>


More information about the es-discuss mailing list