Is this the best way to get access to the parent scope when dealing with complex objects literals?
I find this a bit ugly, and obviously the best solution would never be involving calling it by name directly, but by saving the state of the previous scope. I tried it with bind() but didn't get it to work properly.
var object = {
name : 'foo',
getName : (function(){
return function(that){
return {
a : 111,
b : that.name,
c : function(){
return this.b;
}
}
}(this);
})
};
object.getName().b // 'foo'