Skip to content
Dev.to1 min read

Understanding the this Keyword in JavaScript

JavaScript has a special keyword called this that often confuses beginners. The key idea: this refers to the object that is “calling” the function. Let’s break it down with simple examples. 🧠 this in the Global Context In the global scope: ```js id="global1" console.log(this); * In a browser → points to `window` object * In Node.js → points to `global` object ```id="viz1" Global scope → this = window (browser) / global (Node) 🔹 this Inside Objects When a function is called as a method of an obje
Read original on dev.to
0
0

Comment

Sign in to join the discussion.

Loading comments…

Related

Get the 10 best reads every Sunday

Curated by AI, voted by readers. Free forever.

Liked this? Start your own feed.

0
0