Accessing global variable from asynchronous function


How to access global variable from an asynchronous function? I get that global variable is not defined although it is.


Are you sure you have the proper execution context for ‘this’?


what do you mean by that?

I have global variable myVariable;

In constructor I say this.myVariable = "someValue";

and then in an asynchronous method: console.log(this.myVariable);

and get undefined.

Is that what you mean?