Understanding `this` in JavaScript: Normal vs Arrow Functions

The `this` keyword in JavaScript — explained simply 🧠 `this` confuses many developers at first. The key is: it depends on HOW a function is called. Normal Function 👇 • `this` refers to the object that calls the function • Value is dynamic Arrow Function 👇 • `this` does NOT have its own context • It takes `this` from the parent scope Simple rule to remember: Normal function → its own `this` Arrow function → borrows `this` This is why arrow functions are commonly used in: ✔ Callbacks ✔ React components ✔ Event handlers (carefully) Once this clicks, many bugs disappear 🚀 #javascript #frontenddeveloper #webdevelopment #coding #learningjavascript #reactjs #softwareengineering

  • timeline

To view or add a comment, sign in

Explore content categories