JavaScript: 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 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 }

〔►see JavaScript: 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

var 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 Topic

  1. JavaScript: Property Overview
  2. JavaScript: Property Key
  3. JavaScript: Property Dot Notation / Bracket Notation
  4. JavaScript: Create/Delete Property
  5. JavaScript: Get Property, Set Property
  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.