make object writable js code example
Example: javascript object writable
var person = {name: 'bob', age: 30}
// This sets the name to be read only
Object.defineProperty( person, 'name', {
value: "bob",
writable: false,
});
// This sets the age to be writable
Object.defineProperty( person, 'name', {
value: "age",
writable: true,
});
person.name = 'tim' // this will NOT work
peron.age = 40 // this will work