On Nov 21, 2:50 pm, Spam Catcher <spamhoney...@rogers.comwrote:
When declaring class properties, what's the difference between:
function EventBroker()
{
this.Register = function(eventName, handler)
That will add a Register property to each and every object created
when EventBroker is called as a constructor (in classic OO speak, each
instance of the EventBroker class, noting that javascript does not
have classes). The Register property of any particular instance can
be over ridden independently of all the other instances, if you want
to modify them all, you have to find all instances and modify each
one.
You can't modify the constructor dynamically, although you can replace
the value assigned to it.
//AND
EventBroker.prototype.PropertyName = function() {};
That adds a PropertyName property to the constructor's public
prototype property and assigns an anonymous function to it. All
objects created using EventBroker will have access to the property.
As with the above method, you can over-ride the property on any
particular instance without affecting other instances, but you can
also modify the value for all instances by replacing the value of the
prototype's property (but not for those where the property has been
over-ridden).
What's the difference between this.Property and Class.prototype.Property?
--
Rob