JS: Getter Setter Attributes

By Xah Lee. Date: .

Getter setter property attributes

Every property has special info attached, called Property Attributes.

Getter property attributes

enumerable

Value is Boolean.

configurable

Value is Boolean.

get

Value is a function.

Setter property attributes

enumerable

Value is Boolean.

configurable

Value is Boolean.

set

Value is a function.

No writable, no value attribute

There's no writable attribute, nor value attribute, for getter and setter property.

If a accessor property only has getter, it cannot be written to. If it only has a setter, it cannot be read.

The getter and setter attributes are reflected in its Property Descriptor syntax:

{ get: f, set: f, enumerable: boolean, configurable: boolean }