3 ms·
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.
by sopooneo 14y ago
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?
- deleted 14y ago[deleted]