Hard-Bind a Function's this Value with the .bind() Method

Share this video with your friends

Send Tweet

The Function.prototype.bind() method lets us permanently tie a function's this argument to a specific value. It creates a new bound function that calls the original function with the provided this argument, no matter how that bound function is called.

In this lesson we'll see how to use the bind() method. To better understand how it works, we'll implement a naive version of bind() ourselves.

Kevin Pinny
Kevin Pinny
~ 6 years ago

Important to note that a hard binding can be overwritten by invoking the function with new keyword. So in other words the order of precedence of this is: implicit, explicit (call, apply), hard binding and the one that overrules them all is new.