# Encapsulation

Keeping an object's data behind its methods so it's changed the safe way.

## What is **Encapsulation** in JavaScript?

**Encapsulation** — Keeping an object's data behind its methods so it's changed the safe way.

```javascript
class Thermostat {
    #temperature = 20;

    get temperature() {
        return this.#temperature;
    }
}
```

Level: Journeyman · [More JavaScript terms at this level](https://www.ask-codey.com/glossary/subjects/javascript/journeyman)

Updated: September 27, 2026

## In other subjects

- [Encapsulation in C#](https://www.ask-codey.com/glossary/encapsulation-c-sharp)
- [Encapsulation in Java](https://www.ask-codey.com/glossary/encapsulation-java)
- [Encapsulation in OOP](https://www.ask-codey.com/glossary/encapsulation-oop)

Source: https://www.ask-codey.com/glossary/encapsulation-javascript
