Stay Down Dev Log - Part 11 - Understanding "this" In Destructured Functions

3 years ago
12

In this magical code refactoring dev log, I run into an issue with destructuring functions out of the global object and have to figure out how to fix it. I also fix a position issue with the score counter.

This video will help you understand how the "this" keyword works inside of a function and goes over an issue you may encounter when destructuring functions out of objects. A few solutions I didn't talk about are binding "this" to the destructured function, and using closures to make a local copy of "this" in your function.

What you'll learn in this video:

00:00:54 - Explaining the issue
00:05:10 - A few ways to fix the issue
00:07:03 - Testing a potential oversight with self referencing
00:09:10 - My solution to the problem: private properties!
00:23:00 - Repositioning the score counter

Check out the website for more projects, videos, and source code! https://pothonprogramming.github.io

Join the Discord for some conversation: https://discord.gg/fTNxCXv

Loading comments...