Implementing Protected (Or Trusted, Friend-Class-Like) Methods In Modern ES2022 JavaScript

Опубликовано: 31 Июль 2026
на канале: Brian Katzung
16
1

In    • Securely Implementing Protected Properties...   I talk about implementing protected properties (visible to classes within an inheritance hierarchy, but not outside) and in    • Securely Sharing Data Between Trusted/"Par...   I talk about implementing trusted/partner/friend-class properties (visible to an enumerated list of trusted classes, but not other code).

In this video, I cover several ways to extend those concepts in order to implement protected or trusted *methods*.

Table of contents
00:00 Intro, background, and goals
00:43 "Designated base class" pattern
01:21 Methods added to protected state (bound, closure, unbound)
02:34 Pseudo-protected prototype methods (publicly visible, controlled access via shared secret)
03:34 Calling syntax for each approach
05:13 Demonstration output walk-through
06:05 Chart: comparison of protected-method implementations [no audio]

Please refer to the other video descriptions for relevant GitHub and blog links.

#javascript #objectorientedprogramming #encapsulation