JS: Property Descriptor
What is Property Descriptor
Property Descriptor is the syntax for specifying Property Attributes . It has the form:
{
value: value,
writable: boolean,
enumerable: boolean,
configurable: boolean
}
Property Descriptor for Getter Property
{
get: function,
enumerable: boolean,
configurable: boolean
}
γsee Getter Setter Propertiesγ
Property Descriptor for Setter Property
{
set: function,
enumerable: boolean,
configurable: boolean
}
Get Property Descriptor
Property Descriptor is used by several JavaScript functions to create/set properties together with attributes.
Set Property Descriptor
Default Values of Property Descriptor
value
-
undefined
configurable
-
false
enumerable
-
false
writable
-
false
set
-
undefined
get
-
undefined
// check default values of property attributes const xx = Object.create( Object.prototype, { "p":{value:1} } ); const desc = Object.getOwnPropertyDescriptor(xx, "p"); const defaultX = new Map( [ ["value", 1], ["writable", false], ["enumerable", false], ["configurable", false] ]); console.log( Object.entries ( desc ) . every (([k,v]) => (v === defaultX.get(k))) ); // true
JavaScript, Property
- JS: Property Overview
- JS: Property Key
- JS: Property Dot Notation vs Bracket Notation
- JS: Create Property
- JS: Delete Property
- JS: Get Set Property
- JS: Check Property Existence
- JS: Access Property
- JS: List Properties
- JS: for-in Loop
- JS: Enumerable Property
- JS: Property Attributes
- JS: Property Descriptor
- JS: Getter Setter Properties