Exercises: Encapsulation and "static" – Object Oriented Programming (OOP) – Javascript In Depth



Exercises: Encapsulation and "static" – Object Oriented Programming (OOP) – Javascript In Depth

Exercises: Encapsulation and "static" -  Object Oriented Programming (OOP) - Javascript In Depth

Let’s go through some exercises to get more practice with the concept of Encapsulation as well as the “static” keyword in Javascript together.

We start with a warmup to look at how we can create a private method in a class and how we can call that method internally.

The first main exercise explores the “static” keyword and how it works on a class with a static method.

The second exercise has us explaining the prototype chain of a class, it’s sub-class, and the normal and static properties and methods. We spend a lot of time making sure we understand the entire chain.

The third main exercise has us looking through the Array Object documentation together to look up static and normal methods and properties and how they might work.

We wrap up the exercises with an open-ended Bonus question where we discuss where we’d use the static keyword and private identifier in our own class and object designs.

This is part of a series where we go over Javascript in depth to learn programming concepts as well as web development: https://youtube.com/playlist?list=PLovN13bqAx7D_MFjL0PHnCkYAHMSO8-kU

Chapters:
00:00 Introduction
00:55 Warmup Exercise – Private Method
06:49 Exercise 1 – Static Method
19:58 Exercise 2 – Explaining Prototypes
45:44 Exercise 3 – Array Class Documentation
55:50 BONUS – When to use static and private?
1:05:12 Next Steps

📦 Github Repository with the notes and exercise code+solutions: https://github.com/Nooder/javascript-in-depth
💬 Come join us on Discord to chat with a like-minded community about tech and learning: https://discord.gg/K4nkugP7Gd

Comments are closed.