Prevents the modification of attributes of existing properties, and prevents the addition of new properties.
SyntaxObject.seal( object )
The object that is passed to the function.
ExamplesThe following example illustrates the use of the Object.seal function.
var obj = { pasta: "spaghetti", length: 10 };
Object.seal(obj);
document.write(Object.isSealed(obj));
document.write("<br/>");
obj.newProp = 50;
document.write(obj.newProp);
document.write("<br/>");
delete obj.length;
document.write(obj.length);
Remarks
The Object.seal function does both of the following:
When the configurable attribute is false , property attributes cannot be changed and the property cannot be deleted. When configurable is false and writable is true , the value and writable attributes can be changed.
The Object.seal function does not change the writable attribute.
For more information about how to set property attributes, see Object.defineProperty Function. To get the attributes of a property, you can use the Object.getOwnPropertyDescriptor Function.
The following related functions prevent the modification of object attributes.
Function Object is made non-extensible configurable is set to false for each property writable is set to false for each property Object.preventExtensions Yes No No Object.seal Yes Yes No Object.freeze Yes Yes YesThe following functions return true if all of the conditions marked in the following table are true.
ExceptionsIf the object argument is not an object, a TypeError exception is thrown.
See also Other articlesMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4