Learn how to use bind, call, and apply when the meaning of "this" gets lost. Get a common example of when it is needed while working with events.
- [Instructor] Now that we've seen a few ways…that the meaning of this changes,…let's see how we can force it to be what we want.…There are three ways we can force the meaning of this,…we can use bind, call, or apply.…Call and apply are essentially the same thing…except for you're using an array with apply…and call just takes parameters.…With bind, you can attach the meaning of this…and call it later.…Let's see how that works in our code.…I'm going to create a new person here…and we'll call her Janice,…she's equal to a new person.…
And let's give her a name.…So Janice.name is equal to Janice.…And our VIP employee could go to John…but by using our bind function,…so title myfunction.bind,…and binding Janice to it,…she will always be the meaning of this for the VIP.…So on our next video, lets put these concepts into practice.…
- Working with prototype and dynamic elements
- Using bind, call, and apply
- Using the Fisher–Yates formula
- When to use e.preventDefault() and when to avoid it
- Drag-and-drop life cycle
- Using prototypical inheritance to optimize your code
Skill Level Intermediate
Q: This course was updated on 1/16/2019. What changed?
A: The following topics were updated: propagation and drag and drop.