if i have :
var obj= {
a:"something",
b:{
a:function (){
// Can I access obj properties through the this keyword here
}
}
};
Can I access properties of obj through the this keyword in the obj.b.a function?
Short answer: No.
Long answer: There could be many properties on many objects pointing to the object. Which one would be the parent? Also, read here how the
thiskeyword really works: It only points to theobj.bobject when your function is called withobj.b.a().However, you can still use the
objvariable as a reference. In this answer I have discussed the differences tothis.