"this" keyword in JavaScript - Full Course for Beginners
Gordon Zhu Gordon Zhu
5.82K subscribers
1,777 views
90

 Published On May 30, 2023

Learn to think about JavaScript's `this` keyword in a powerful way that works in every conceivable situation.

Flowchart: https://watchandcode.com/essays/this/
My teaching: https://watchandcode.com

Understand how "this" works with:
Normal function calls
Method calls
Callback functions
Regular and class constructor functions
The `new` keyword
Arrow functions
`bind`, `call`, and `apply`
`super` keyword, both super(), and super.method()
Built-in functions (like addEventListener and array methods like forEach)

JavaScript's "this" keyword is particularly difficult because you can't figure out what's happening with pure logic. Some prerequisite knowledge is required to make sense of things because it interacts with many parts of the language, and has gotten more complicated over time with the introduction of ES6.

0:00 Introduction
1:30 Definitions
3:08 Common Case
10:56 bind/call/apply
11:51 new keyword
16:25 Arrow functions
17:56 super.method()
21:37 Built-in functions
32:23 How to Practice & Closing Thoughts

Acknowledgements: Thanks to Janelle de Ment, James Squillante, and Lily Gentner for reviewing drafts of this lesson.

show more

Share/Embed