Example, lets say I have the following Constructor function defined in window global of a browser.
function AccessProperty() {
this.myName = "Chris";
}
Now I execute this function like this:
new AccessProperty();
Now based on how I executed the function above with the new keyword, how can I access this.myName property without adding something like this:
var acccess = new AccessProperty();
(new AccessProperty()).myNamelike this?access.myNamenew AccessProperty()somewhere, then you cannot access that value. Can you provide more information?AccessPropertycan perform side effects and store the value in a different place. You could change the implementation ofAccessPropertytovar obj = {}; function AccessProperty() { obj.myName = "Chris"; }; new AccessProperty(); console.log(obj.myName);but I wouldn't advice doing that. It's hard to help without knowing the actually problem you are trying to solve.