Open utkarsh-1602 opened 4 months ago
I guess, when you call "data.getStatus.call(this)", getStatus method setting the value of "this" to global object. But inside getStatus method, "this.status" trying to access global object property , not the status property inside setTimeout.
If we change getStatus function to arrow function, issue will get resolved.
getStatus(){ return this.status; }
@ManjulaP1012 actually the expected output should be "online" as this
is pointing to global object status. but I'm not understanding why its returning undefined
this is my program
why
console.log(data.getStatus.call(this))
is returningundefined
?