Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026
The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.
When you define a property on a class, once you have an object you can access that property freely, getting and setting its value.
Sometimes however it’s important to keep things private.
We can use private class fields that enforce private fields:
class Counter {
#count = 0
increment() {
this.#count++
}
}
We now can’t access this value from the outside.
You need to add a method to get its value:
class Counter {
#count = 0
increment() {
this.#count++
}
getCount() {
return this.#count
}
}
const counter = new Counter()
counter.increment()
counter.increment()
console.log(counter.getCount()) Lessons in this unit:
| 0: | Introduction |
| 1: | Classes |
| 2: | Class methods |
| 3: | ▶︎ Private class properties |
| 4: | Constructors |
| 5: | Inheritance |
| 6: | Prototypes |