Read-only property

suggest change

Using 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

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents