Skip to content

Property Descriptors

Every property in JavaScript has a property descriptor — an object that describes its behavior. The three main attributes are writable, enumerable, and configurable.

flowchart TD
A["Property Descriptors"]
B["writable: Can value be changed?"]
C["enumerable: Shows up in loops?"]
D["configurable: Can descriptor be changed?"]
A --> B
A --> C
A --> D
const user = { name: 'Alice' };
const descriptor = Object.getOwnPropertyDescriptor(user, 'name');
// { value: 'Alice', writable: true, enumerable: true, configurable: true }
  • writable — true if the value can be changed
  • enumerable — true if it appears in for...in and Object.keys()
  • configurable — true if the descriptor can be changed or property deleted
  • Every property has a descriptor with 3 boolean flags
  • writable — can the value change?
  • enumerable — does it appear in iteration?
  • configurable — can the descriptor be modified?