Static method Object.seal()
The Object.seal() static method seals an object.
Sealing an object prevents extensions and makes
existing properties non-configurable. A sealed
object has a fixed set of properties: new
properties cannot be added, existing properties
cannot be removed, their enumerability and
configurability cannot be changed, and its
prototype cannot be re-assigned. Values of
existing properties can still be changed as long
as they are writable. seal() returns the same
object that was passed in.
const object1 = {
property1: 42
};
Object.seal(object1);
object1.property1 = 33;
console.log(object1.property1);
// Expected output: 33
delete object1.property1; // Cannot delete when sealed
console.log(object1.property1);
// Expected output: 33