Read-only property
suggest changeUsing property descriptors we can make a property read only, and any attempt to change it’s value will fail silently, the value will not be changed and no error will be thrown.
The writable
property in a property descriptor indicates whether that property can be changed or not.
var a = { };
Object.defineProperty(a, 'foo', { value: 'original', writable: false });
a.foo = 'new';
console.log(a.foo);
Console output
original
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents