News for hackers. Stuff that matters.
Re:JavaScript Prototypes Made Easy by sopooneo on Sunday July 01, 2012 @12:42AM (#4183872)
If I am reading this right, then you can get efficiency gains by attaching methods to an object's prototype rather than defining them directly in a constructor. This way, the method is only created once, and is just reference by all instances of whatever object.

If I am correct about all that, my point of confusion is simply that this seems like a very awkward way to design things. Isn't it easier to read a program if all of an object's properties and methods are defined together in it's constructor, rather than spread out later as attachments to a prototype?

There are no comments on this comment yet.