JS: Property Descriptor

By Xah Lee. Date: . Last updated: .

Property Descriptor is the syntax for setting and displaying property's attributes. It has the form:

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

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

Property Descriptor is used by several JavaScript functions to create/set properties together with attributes. For example,

and some functions return a property descriptor:

Property Descriptor for Getter Property

Property Descriptor for getter property is:

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

[see JS: Getter/Setter Properties]

Property Descriptor for Setter Property

Property Descriptor for setter property is:

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

Default Values of Property Descriptor

Property Descriptor default values:

//  default values of property attributes

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

console.log(  Object.getOwnPropertyDescriptor(xx, "p") );
// prints
// { value: 1,
//   writable: false,
//   enumerable: false,
//   configurable: false }

ECMAScript 2015 §ECMAScript Data Types and Values#table-4


ECMAScript® 2016 Language Specification#sec-property-descriptor-specification-type

JS Object Property

  1. Property Overview
  2. Property Key
  3. Dot vs Bracket Notation
  4. Create/Delete Property
  5. Get/Set Property
  6. Check Property Existence
  7. Access Property
  8. List Properties
  9. Property Attributes
  10. Getter/Setter
  11. Property Descriptor
  12. Symbol
Liket it? Put $5 at patreon.

Or, Buy JavaScript in Depth

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

Web Dev Tutorials

  1. HTML
  2. Visual CSS
  3. JS in Depth
  4. JS Reference
  5. DOM
  6. SVG
  7. Web Dev Blog