DEV Community

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

Rajat 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
 
rajat05 profile image
Rajat • 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
 
rajat05 profile image
Rajat

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

Collapse
 
ridhikgovind profile image
Ridhik Govind

Really good explanation Rajat ! :)

Collapse
 
rajat05 profile image
Rajat

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
 
rajat05 profile image
Rajat

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
 
rajat05 profile image
Rajat

Haha My pleasure, buddy!

Collapse
 
thekooldev1232 profile image
thedev1232

nice ansd simple

Collapse
 
rajat05 profile image
Rajat

Thank you!