how to simply make a reference to this
(the obj
) in this simple example? (and in this exact case, using obj. literal)?
var obj = {
planet : "World!", // ok, let's use this planet!
text : {
hi: "Hello ",
pl: this.planet // WRONG scope... :(
},
logTitle : function(){
console.log( this.text.hi +''+ this.planet ); // here "this" works !
}
};
obj.logTitle(); // WORKS! // "Hello World!"
console.log( obj.text.hi +''+ obj.text.pl ); // NO DICE // "Hello undefined"
I tried also making that : this,
but again that
is undefined inside the inner object