DEV Community


Prevent an object's properties value from updating

318097 profile image Mehul Lakhanpal Originally published at ・1 min read
const obj = {name: 'Codedrops'};
console.log(; // Codedrops

/* Set the 'writable' descriptor to false for the 'name' key  */
Object.defineProperty(obj, 'name', {
        writable: false
}); = 'ABC';
console.log(; // Codedrops
Enter fullscreen mode Exit fullscreen mode

Thanks for reading 💙

Follow for daily posts.


Micro-Learning ● Web Development ● Javascript ● MERN stack ● Javascript

Discussion (2)

Editor guide
lowlighter profile image
lowlighter 🦑

One may look also at Object.seal and Object.freeze, to respectively prevent an object from being extended with new properties or to be modified in any way

318097 profile image
Mehul Lakhanpal Author

Yes, but there is a small difference between all of them. Have a post coming up..