I have a resource object like so:
var resource = {
...
All sorts of nifty stuff;
...
};
I'd like to create a function expression on the fly and refer to other functions in my resource object with the keyword this
:
resource.url = function(){
return this.constructbaseUrlParams() +
this.constructReqeustParams();
}();
but this
refers to the window
object here.
I know I can use:
resource.url = function(){
return resource.constructbaseUrlParams() +
resource.constructReqeustParams();
}();
But I'd like to use this
so the function can be more modular and perhaps allow me to create multiple resource objects in the future without issue.