Learn JavaScript 041: call, apply, and bind Explained (The 'this' Keyword)
Code Kaizen
0:00 / 0:00
Learn JavaScript 041: call, apply, and bind Explained (The 'this' Keyword)
3 просмотра · 7 дней назад
Code Kaizen
12 подписчиков
3 просмотра · 7 дней назад
Welcome back to the Complete JavaScript Course! Have you ever tried to pass a method into an event listener or a React component, only to have your code crash with Cannot read properties of undefined? You just fell victim to the most infamous bug in JavaScript: losing the this context.
In this video, we master the this keyword once and for all. When you extract a method from an object, it instantly forgets where it came from. I will show you how to manually force the this keyword to point exactly where you want it using three powerful methods: .call(), .apply(), and .bind(). We will look at the "Airline Booking" scenario to borrow methods between objects, and I will share the "Taxi vs Buying a Car" analogy to ensure you never confuse call and bind again!
#JavaScript #WebDevelopment #LearnToCode #ThisKeyword #JavaScriptTips #ReactJS #FrontendDevelopment #SoftwareEngineering #CodingTutorial