javascript object read only
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
Also in JavaScript:
- javascript regex single line
- REACt helmet og tags DONT WORK
- how to adjust brightness with a slider in javascript
- js 1d index to 2d coord
- install nodejs ubuntu 19.04
- $.ajax javascript
- Hoisting in JavaScript MDN
- create global variable inside function JavaScript
- How to get the input from a textbox javascript
- .push js
- jquery safely use $
- javascript disable scrolling
- D3.js
- javascript void(0) href
- how to change the font family using jquery
- get the first word from a string jquery
- if str contains jquery
- navigation.openDrawer is not a function react native
- No matching version found for swagger-jsdoc@^6.0.0.
- get object with max value javascript
- IFFI in js
- js json stringfy beutify
- send message to user facebook game
- javascript array remove last