| title | ms.custom | ms.date | ms.prod | ms.reviewer | ms.suite | ms.technology | ms.tgt_pltfrm | ms.topic | dev_langs | helpviewer_keywords | ms.assetid | caps.latest.revision | author | ms.author | manager | ||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Object.isExtensible Function (JavaScript) | Microsoft Docs |
01/18/2017 |
windows-client-threshold |
|
language-reference |
|
|
a7d10beb-0d01-4e2d-8263-59ff07ac4352 |
10 |
mikejo5000 |
mikejo |
ghogen |
Returns a value that indicates whether new properties can be added to an object.
Object.isExtensible(object) object
Required. The object to test.
true if the object is extensible, which indicates that new properties can be added to the object; otherwise, false.
If the object argument is not an object, a TypeError exception is thrown.
For information about how to set property attributes, see Object.defineProperty Function. To obtain 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 | Yes |
The following functions return true if all of the conditions marked in the following table are true.
| Function | Object is extensible? | configurable is false for all properties? |
writable is false for all data properties? |
|---|---|---|---|
Object.isExtensible |
Yes | No | No |
| Object.isSealed | No | Yes | No |
| Object.isFrozen | No | Yes | Yes |
The following example illustrates the use of the Object.isExtensible function.
// Create an object that has two properties.
var obj = { pasta: "spaghetti", length: 10 };
// Make the object non-extensible.
Object.preventExtensions(obj);
// Try to add a new property, and then verify that it is not added.
obj.newProp = 50;
document.write(obj.newProp);
// Output:
undefined
[!INCLUDEjsv9]
Object.preventExtensions Function
Object.seal Function
Object.freeze Function
Object.isSealed Function
Object.isFrozen Function