In javascript, an object has no concept of this .
The meaning of the this is determined in the function by how this function is called.
For example, in myObj , if you do this:
myObj.readCookie('someName');
Then, inside the readCookie this function, readCookie will be set.
If you want site_brand call the readCookie function, you must give site_brand your own function that calls it:
site_brand: function() { return this.readCookie('aCookieName'); },
... and name it like this:
myObj.site_brand()
... so this inside the site_brand function is a reference to myObj .
EDIT: The code in the question has changed a bit (due to formatting, I think).
The answer is the same, but I would just notice that calling this.site_brand in the SaySomeThing function SaySomeThing fine as long as myObj was called from SaySomeThing .
// this is fine SaySomeThing: function() { alert(this.site_brand); } // as long as you're calling it something like myObj.SaySomeThing();
source share