- How do I create a read only property?
- How do I make an unenumerable property?
- How do I make property not configurable?
- How do I determine whether a property is read only?
You can answer all these questions when you understand Property Descriptors.
Let’s consider the code below:
Here, your output will be as follows:
As you can see here, there are four characteristics of a property:
The value holds the data of the property, whereas writeable, enumerable, and configurable describe other characteristics of the property. Let’s take a closer look at each of these characteristics in the rest of this post.
The error message here says you cannot assign something to a read only property. Here, aproperty acts as a read only property if the writable characteristic of the property is set to false.