I append a services
property to this
:
function Client(){
this.services = {
'propertyName' : {}
};
and then append a method to this
, in which I need to reference the services
property of the instance of client
:
function Client(){
this.services = {
'propertyName' : {}
};
this.someMethod = function () {
if (this.services['propertyName']) {
//do something
}
}
}
var clientName = new Client();
But this.services - line 6
is undefined. How can I use a property assigned to this
in a method assigned to this
? It seems like it should be possible because by the time that method is called by the constructor, the services
property will exist for the object. Is this a language limitation? Is it possible? Should it be?