I have a class and it has a constructor.
I assign a class variable by this.something
and it is not being accessed in some another function inside the same class.
Following is my class
class A {
some_func() {
console.log(this.var1); // this is giving undefined
}
constructor(socket, var1) {
this.socket = socket;
this.var1 = var1;
this.socket.on('some event', some_func);
}
}
Inside the some_func
function the variable is undefined.
How do i fix that?