From the course: Mastering Web Developer Interview Code

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Describe when you should use the bind() method

Describe when you should use the bind() method

From the course: Mastering Web Developer Interview Code

Describe when you should use the bind() method

- [Instructor] This week we'll take a look at one of those gotcha pieces of code that you might see in an interview, since it tests your understanding of two important concepts in JavaScript, the "This" keyword, as well as data binding. So there is a special keyword in JavaScript called "This". And it's really important and powerful, and it's obviously hard to talk about it without saying the word "This" when you don't meet or so. So we'll give it a shot here. Now that "This" key word has different meanings depending on the context that it's in. So that means where it is in your code. And so if you don't understand what it's doing, it can lead to unexpected results. So it's pretty important that you have some practice using it. Now there are instances where we want to redefine the meaning of this. And we can do that with the bind method. A bind allows you to execute some code, while at the same time redefining the…

Contents