What is binding in JavaScript?

Som Ramnani
Jan 24, 2021
Image taken from Unsplash

In JavaScript the bind() method creates a new function and sets this to a specific value.

For instance, here we have a simple object:

Then we use the bind() method to set the context of this to the person object:

When it is all done and the function is invoked it will look like this:

--

--

Som Ramnani
0 Followers

A web developer with a passion for technology and ambition to keep growing in programming.