JavaScript: Property Descriptor

By Xah Lee. Date: . Last updated: .

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

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

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

〔►see JavaScript: Property Attributes

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

and some function returns a property descriptor:

Property Descriptor for Getter Property

Property Descriptor for getter property is:

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

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:

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

// shows default values of attributes when using Object.defineProperty()

var ox = {};

// empty property descriptor
Object.defineProperty(ox, "p", {} );

// show attributes
 Object.getOwnPropertyDescriptor(ox, "p")
// { value: undefined, writable: false, enumerable: false, configurable: false }


JS Object Property Topic

  1. JavaScript: Property Overview
  2. JavaScript: Property Key
  3. JavaScript: Dot Notation vs Bracket Notation for Properties
  4. JavaScript: Create/Delete Property
  5. JavaScript: Read/Write to Property and Prototype Chain
  6. JavaScript: Check Property Existence
  7. JavaScript: Access Property, List Properties
  8. JavaScript: Property Attributes
  9. JavaScript: Getter/Setter Properties
  10. JavaScript: Property Descriptor
Like what you read? Buy JavaScript in Depth
or, buy a new keyboard, see Keyboard Reviews.