DEV Community

bind(), call(), and apply() in JavaScript

RAJAT MEHRA on December 06, 2020

While coding in JavaScript, I'm always perplexed on how JavaScript works. It's just as Kyle Simpson says - "I don’t think anyone ever really kn...
Collapse
 
fonta22 profile image
Fonta22

Really nice post. I finally understood the .bind method!

Collapse
 
rajatmehra05 profile image
RAJAT MEHRA • Edited

Thank you ❤ I'm glad it was useful to you :)

Collapse
 
dcsan profile image
dc

nice! these are always a bit confusing. It would be nice to explain by example when you might use these. For example I've used call for a string templating when I don't want to pass a bunch of parameters. It feels a bit code-smelly tho definitely "side effects" reaching into the caller object for state.

Collapse
 
rajatmehra05 profile image
RAJAT MEHRA

I suggest you go through this link - medium.com/javascript-scene/master...

Collapse
 
ridhikgovind profile image
Ridhik Govind

Really good explanation Rajat ! :)

Collapse
 
rajatmehra05 profile image
RAJAT MEHRA

Thank you bro :)

Collapse
 
bgrand_ch profile image
Benjamin Grand

Thanks a lot!

Collapse
 
mikcompany profile image
Mikko

Thanks for the explanation! Nice and compact info about nuances of .call() and .apply() 👍

Collapse
 
rajatmehra05 profile image
RAJAT MEHRA

I'm glad you liked the explanation. Thank you😊

Collapse
 
chetanchandel31 profile image
chetanchandel31 • Edited

Definitely filled some gaps in my knowledge of fundamentals🔥.

Collapse
 
rajatmehra05 profile image
RAJAT MEHRA

Haha My pleasure, buddy!

Collapse
 
thekooldev1232 profile image
thedev1232

nice ansd simple

Collapse
 
rajatmehra05 profile image
RAJAT MEHRA

Thank you!