Getters and Setters
Defining object properties backed by functions that run on access or assignment, letting you compute values or add validation transparently.
Getters and setters let you define an object property that, from the outside, looks and behaves exactly like a plain data property — accessed and assigned with ordinary dot notation — but is actually backed by functions that run automatically on read or write. This is a useful but sometimes overlooked feature, and interviewers ask about it to check whether you know JavaScript objects support more than plain key-value pairs.
A getter/setter pair is like a smart thermostat display: you read a single number (the property) that's actually computed live from several sensors (a getter), and when you dial in a new target temperature (a setter), the internal system runs it through validation and translates it into the actual settings, all while you just interact with one simple dial.