I am new to javascript and many aspects seem counter intuitive. Am I correct in understanding that if I define:
var A = function() {
return {
d:"property-of-object-returned-by-constructor",
method:function() {
d = "Not my property";
}
}
}
myObj = new A();
Am I correct that the only way to refer to property d inside of myObj.method() is to use this.d?
For example, am I correct that as it stands myObj.method() doesn't change the property d but actually creates a global variable d that is completely unrelated to myObj.d?
I believe that is what I am seeing in my code, but it is counter intuitive that "this" would be the sole way to refer to one's own properties, rather than simply referring to them directly. So maybe I am misunderstanding something.