JavaScriptHard
What are JavaScript object property flags and descriptors?
By FrontendPro Editorial Team Updated 8/8/2026
#JavaScript
Answer
In JavaScript, property flags and descriptors manage the behavior and attributes of object properties.
Property flags
Property flags are used to specify the behavior of a property on an object. Here are the available flags:
writable: Specifies whether the property can be written to. Defaults totrue.enumerable: Specifies whether the property is enumerable. Defaults totrue.configurable: Specifies whether the property can be deleted or its attributes changed. Default istrue.
Property descriptors
These provide detailed information about an object's property, including its value and flags. They are retrieved using Object.getOwnPropertyDescriptor() and set using Object.defineProperty().
The use cases of property descriptors are as follows:
- Making a property non-writable by setting
writable: falseto ensure data consistency. - Hiding a property from enumeration by setting
enumerable: false. - Preventing property deletion and modification by setting
configurable: false. - Freezing or sealing objects to prevent modifications globally.
