class prototype object vs class instance properties

Garrett dhtmlkitchen at gmail.com
Sat Aug 18 10:13:31 PDT 2007



liorean wrote:
>> What would be the benefit of a class having a prototype over 9instance
>> properties/methods?
> 
> Prototype properties can be shadowed by instance properties without
> being changed, prototype properties are fallbacks if the instance
> property does not exist, and prototype properties are not part of the
> actual instance, so can be used as memory footprint reduction if one
> has lots of instances that don't need separate values for that
> instance property.
> -- 

That's pretty much how es3 works, then. 

Instance methods in the prototype, unique properties will be defined on the
instance.




-- 
View this message in context: http://www.nabble.com/class-prototype-object-vs-class-instance-properties-tf4288010.html#a12215225
Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at Nabble.com.




More information about the Es4-discuss mailing list