The Object.seal() method is used to seal an object, by preventing new properties from being added to it and marking all existing properties as non-configurable.
But values of present properties can still be changed as long as they are writable. Let’s see the below example to understand more about seal() method
1 2 3 4 5 6 7 8 | const object = { property: 'Welcome JS world' }; Object.seal(object); object.property = 'Welcome to object world'; console.log(Object.isSealed(object)); // true delete object.property; // You cannot delete when sealed console.log(object.property); //Welcome to object world |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.