Im trying to write some OOP in javascript, and I stumbled upon a problem that I am sure Im going to have later on in my code and wish to deal with it now.
for example take this code:
var FeedClass = function(){
this.init = function(){
this.loadItems();
},
this.loadItems = function(){
var that = this; // heres my problem
function inner(){
that.startLoading();
}
inner();
},
this.startLoading = function(){
alert("started Loading");
}
this.init();
};
var feed = new FeedClass();
the problem is Im going to use a lot of inner functions that will call "this", my code will be messy if I kept writing var that = this inside every scope. Is there another pattern I can use or a way to get around it?