This Keyword Javascript
-
What is
thiskeyword?- The
thiskeyword refers to the context where a piece of code, such as a function's body, is supposed to run. thiskeyword is used to reference something, like an object- It depends on the context it is used in.
- This never points to a function its points to its context
- The
-
Global Context
// here this is the global object, window in browser this.a = 5; console.log(this); // { a: 5, ...}