# Setter

*noun*

say it: **“SET-er”** **/ˈsɛtər/**

A method marked with set that runs when code assigns a property, so it can check the new value before storing it.

## What is **Setter** in JavaScript?

**Setter** — A method that validates or changes an object's stored value.

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

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

## In a sentence

- “The **setter** refuses an age below zero, so pet.age = -3 throws an error.”

Level: Journeyman · [More JavaScript terms at this level](https://www.ask-codey.com/glossary?category=javascript&level=3)

Updated: November 9, 2026

## In other subjects

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

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