Do you know about writable, configurable & configurable these property descriptor in JavaScript ?
The age property in this code serves to store the age of a Member object. By defining the age property with writable, configurable, and enumerable flags set to false, the code is essentially creating a read-only property that cannot be changed or deleted once it has been set. This helps ensure that the age property remains accurate and consistent throughout the lifetime of the Member object, and that it cannot be accidentally or maliciously modified or deleted.
If an attempt is made to modify the age property, as shown in the example code with anam.age=24, the operation will fail silently and the age property will retain its original value. Similarly, attempts to delete the age property with delete anam.age will also fail silently, and the property will continue to exist on the object.
Top comments (0)