JavaScript: Property Attributes

By Xah Lee. Date: . Last updated: .

Property Attributes

Each property has associated info called attribute.

ECMAScript® 2016 Language Specification#sec-property-attributes

For data property, their attributes are:

Data Property Attributes
attribute namemeaning
value The property's value.
writable When true, the property's value can be changed.
enumerable When true, the property shows in some loop constructs, such as for-in Loop. 〔►see JavaScript: Access Property, List Properties
configurable If false, attempts to delete the property, change the property to be an accessor property, or change its attributes (other than [[Value]], or changing [[Writable]] to false) will fail.

For accessor property's attributes, see: JavaScript: Getter/Setter Properties.

〔►see JavaScript: Property Overview

Show Property Attributes

〔►see JavaScript: Object.getOwnPropertyDescriptor

〔►see JavaScript: Reflect.getOwnPropertyDescriptor

Create/Modify Property Attributes

〔►see JavaScript: Object.defineProperty

Create/Modify Multiple Properties

〔►see JavaScript: Object.defineProperties

Checking Property's Enumerable Attribute

One convenient function is obj.propertyIsEnumerable(p).

This is convenient if you just want to check a property's enumerable attribute.

〔►see JavaScript: Object.prototype.propertyIsEnumerable

Accessor Property's Attributes

Note: Accessor properties don't have “writable” nor “value” attribute. But getter property has a “getter” attribute, and setter property has a “setter” attribute. Their values are functions.

〔►see JavaScript: Getter/Setter Properties

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.