MDN Javascript.info Mastering The JavaScript This Keyword The meaning of thethiskeyword depends on how and where the function is called, not where it is declared. Its meaning changes every time a function is called from different execution context. Why execution context? Becausethiskeyword is ...
Solution 3: As suggested by other replies, binding your method call tothisis one of the two alternatives to solve your problem and maintain context. setTimeout(this.logout.bind(this), 1000); Another option is to define the logout function as a variable, which allows you to maintain contex...