
The Magic of this, call(), apply(), and bind()
Hello readers 👋, welcome back to 10th blog in this JavaScript series . Imagine you're at a party, and someone shouts, "Hey, come here!" Who will respond? It depends on who is calling and who they're looking at. In JavaScript, the this keyword works exactly like that. It's a special word that refers to the context – the object that is currently "calling" the function. But sometimes, you want to control who this refers to. That's where the magical trio – call() , apply() , and bind() – come into play. In this blog, we'll demystify this and learn how to bend it to our will using these methods. What is this in JavaScript? (The Simple Explanation) this is a keyword that refers to the object that is executing the current function. Think of it like this: when a function is called, this is like a secret note that tells the function, "Hey, you're working for this object right now." Simple rule: this refers to who is calling the function . this Inside Normal Functions When you use this inside a
Continue reading on Dev.to Webdev
Opens in a new tab


