say I create someObj like this
var someObj = function(){
var self = this;
//use this normally
document.body.addEventListener('click',function(){
//use self because this is unavailable
},false)
}
new someObj();
In the event this is not the someObj which id like to use but in this case the body element. Is there a best practice way to get someObj or is declaring some self var like in the example considered any good?
Using
selfseems fine to me.You might also want to check out using
callorapply(see for example odetocode and specifically aboutthisin this post)