JS: Property Descriptor

By Xah Lee. Date: . Last updated: .

Property Descriptor is the syntax for specifying property's attributes. It has the form:

{ value: value, writable: boolean, enumerable: boolean, configurable: boolean }

[see JS: Property Attributes, writable, enumerable, configurable]

Property Descriptor for Getter Property

{ get: function, enumerable: boolean, configurable: boolean }

[see JS: 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

//  default values of property attributes

let xx = Object.create( Object.prototype, { "p":{value:1} } );

Object.getOwnPropertyDescriptor(xx, "p")

// prints
// { value: 1,
//   writable: false,
//   enumerable: false,
//   configurable: false }

JS Object Property

  1. Property Overview
  2. Property Key
  3. Dot vs Bracket Notation
  4. Create/Delete Property
  5. Get/Set Property
  6. Property Existence
  7. Access Property
  8. List Properties
  9. Property Attributes
  10. Getter/Setter
  11. Property Descriptor
  12. Symbol
Like it? Help me by telling your friends. Or, Put $5 at patreon.

Or, Buy JavaScript in Depth

If you have a question, put $5 at patreon and message me.

Web Dev Tutorials