JavaScript Class_private Guide
Private class fields (#) provide true encapsulation in JavaScript, enforced by the runtime. The guide walks through Private Features. `class Demo { #privateField; static #privateStatic; #privateMethod() {} get #privateGetter() {} }`. Private fields are truly private (not just convention). TypeError if accessed outside class. No runtime introspection. Private methods can be static or instance. Private static fields for shared hidden state. Supported in all major browsers since 2021. The guide is organized into 1 sections that build on each other, each pairing a prose explanation with runnable code. Related guides: Arrays, Strings, Numbers, Math, Date. This is one of 145 JavaScript guides on JS Reference — see the full list on the guides page. Practice what you learn in the JavaScript playground, and look up any unfamiliar term in the JavaScript glossary.