Mid From PDF JavaScript JavaScript

How does the “this” keyword work in different contexts?

Context this Refers To

Follow me on LinkedIn:

Global window or global

Method The object owning the method

Constructor The new instance

Arrow function Lexical (surrounding) scope

Example:

const obj = {

value: 10,

show: function() { console.log(this.value); }

obj.show(); // 10

More from JavaScript Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details