Menu

The Magic of this, call(), apply(), and bind() in JavaScript
🖼️

The Magic of this, call(), apply(), and bind() in JavaScript

DEV Community·Anoop Rajoriya·6 months ago
#hiOCqOjg
#this#difference#javascript#call#apply
Reading 0:00
15s threshold

The this is the final boss of the javascript developers. It's slippery, contaxtual, and changes its meaning based on where it called. Understanding it along with call , apply and bind is the moment where you stop guessing what your code do and stat knowing.

Content List

What this means in JavaScript (simple explanation)

this inside normal functions

this inside objects

What call() does

What apply() does

What bind() does

Difference between call, apply, and bind

What this means in JavaScript (simple explanation)

Think of this as dynamic noune like "i" or "me"

if i say "i am eating" the word "i" refer to me, if you say same sentance then "i" refer to you. The sentace is same but subject is change depending on who is speaking.

In javascript this refer to the object which currently executing the code.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.