课程: Mastering Web Developer Interview Code

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Describe when you should use the bind() method

Describe when you should use the bind() method

课程: 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…

内容