Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
Think of a property descriptor as a detailed instruction manual for each property! Every object property isn't just a value - it has hidden settings (metadata) that control how it behaves. Property descriptors let you read these settings and understand what you can and can't do with a property.
For regular properties that store values
The actual value stored
Can the value be changed?
For computed properties with get/set
Function called when reading
Function called when writing
Shows up in for...in loops and Object.keys()
Can the descriptor be changed or property be deleted?
Use Object.getOwnPropertyDescriptor() to see property settings
See how each flag affects property behavior
| Flag | Default (normal) | Default (defineProperty) | Controls |
|---|---|---|---|
value | assigned value | undefined | The property's value |
writable | true | false | Can change the value? |
enumerable | true | false | Shows in for...in, keys()? |
configurable | true | false | Can delete or redefine? |
get | undefined | undefined | Getter function |
set | undefined | undefined | Setter function |
Object.getOwnPropertyDescriptor(obj, prop)Get descriptor for a single property
Object.getOwnPropertyDescriptors(obj)Get all descriptors for all own properties
Object.defineProperty(obj, prop, descriptor)Define or modify a property with specific descriptor
Object.defineProperties(obj, descriptors)Define or modify multiple properties at once
Descriptors are hidden metadata about property behavior
value, writable, enumerable, configurable
Data descriptors (value) and accessor descriptors (get/set)
Use getOwnPropertyDescriptor() to inspect