The this Keyword
Learn The this Keyword (Modern JavaScript (ES6+), JavaScript) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
this - Determined by HOW a Function is Called Unlike variable scope, this is NOT determined by where a function is defined - it is determined by how the function is called at the call site. • Regular function call: this is the global object ( undefined in strict mode/modules). • Method call ( obj.method() ): this is the object before the dot. • Arrow functions: do NOT have their own this - they lexically inherit this from the enclosing scope where they were defined.