Revision 74638 of Object.isExtensible()

  • Revision slug: JavaScript/Reference/Global_Objects/Object/isExtensible
  • Revision title: isExtensible
  • Revision id: 74638
  • Created:
  • Creator: evilpie
  • Is current revision? No
  • Comment 1 words added, 5 words removed

Revision Content

{{ js_minversion_header("1.8.5") }}

Summary

Determines if an object is extensible (whether it can have new properties added to it).

Method of Object
Implemented in JavaScript 1.8.5
ECMAScript Edition ECMAScript 5th Edition

Syntax

Object.isExtensible(obj)

Parameters

obj
The object which should be checked.
extensible
boolean which indicates if the object allows extensions.

Description

Objects are extensible by default: they can have new properties added to them, and (in engines that support __proto__ {{ deprecated_inline() }} their __proto__ property) can be modified. An object can be marked as non-extensible using Object.preventExtensions, Object.seal, or Object.freeze.

Examples

// New objects are extensible.
var empty = {};
assert(Object.isExtensible(empty) === true);

// ...but that can be changed.
Object.preventExtensions(empty);
assert(Object.isExtensible(empty) === false);

// Sealed objects are by definition non-extensible.
var sealed = Object.seal({});
assert(Object.isExtensible(sealed) === false);

// Frozen objects are also by definition non-extensible.
var frozen = Object.freeze({});
assert(Object.isExtensible(frozen) === false);

See also

Revision Source

<p>{{ js_minversion_header("1.8.5") }}</p>
<h3 name="Summary">Summary</h3>
<p>Determines if an object is extensible (whether it can have new properties added to it).</p>
<table class="standard-table"> <thead> <tr> <th class="header" colspan="2">Method of <a href="/en/JavaScript/Reference/Global_Objects/Object"><code>Object</code></a></th> </tr> </thead> <tbody> <tr> <td>Implemented in</td> <td>JavaScript 1.8.5</td> </tr> <tr> <td>ECMAScript Edition</td> <td>ECMAScript 5th Edition</td> </tr> </tbody>
</table> <h3 name="Syntax">Syntax</h3>
<p><code>Object.isExtensible(<em>obj</em>)</code></p>
<h3 name="Parameters">Parameters</h3>
<dl> <dt>obj</dt> <dd>The object which should be checked.</dd> <dt><code>extensible</code></dt> <dd>boolean which indicates if the object allows extensions.</dd>
</dl>
<h3 name="Description">Description</h3>
<p>Objects are extensible by default: they can have new properties added to them, and (in engines that support <code><a href="/en/JavaScript/Reference/Global_Objects/Object/proto" title="en/JavaScript/Reference/Global Objects/Object/proto">__proto__</a></code> {{ deprecated_inline() }} their __proto__ property) can be modified. An object can be marked as non-extensible using <code><a href="/en/JavaScript/Reference/Global_Objects/Object/preventExtensions" style="text-decoration: none; color: rgb(4, 137, 183) !important; cursor: default; " title="en/Core
JavaScript 1.5 Reference/Global Objects/Object/preventExtensions">Object.preventExtensions</a></code>, <code style="color: inherit; font-weight: inherit; text-decoration: none; cursor: default; "><a href="/en/JavaScript/Reference/Global_Objects/Object/seal" style="text-decoration: none; color: rgb(4, 137, 183) !important; cursor: default; " title="en/Core
JavaScript 1.5 Reference/Global Objects/Object/seal">Object.seal</a></code>, or <code style="color: inherit; font-weight: inherit; text-decoration: none; cursor: default; "><a href="/en/JavaScript/Reference/Global_Objects/Object/freeze" style="text-decoration: none; color: rgb(4, 137, 183) !important; cursor: default; " title="en/Core
JavaScript 1.5 Reference/Global Objects/Object/freezed">Object.freeze</a></code>.</p>
<h3 name="Examples">Examples</h3>
<pre class="deki-transform">// New objects are extensible.
var empty = {};
assert(Object.isExtensible(empty) === true);

// ...but that can be changed.
Object.preventExtensions(empty);
assert(Object.isExtensible(empty) === false);

// Sealed objects are by definition non-extensible.
var sealed = Object.seal({});
assert(Object.isExtensible(sealed) === false);

// Frozen objects are also by definition non-extensible.
var frozen = Object.freeze({});
assert(Object.isExtensible(frozen) === false);
</pre>
<h3 name="See_also">See also</h3>
<ul> <li><strong><a href="/en/JavaScript/Reference/Global_Objects/Object/preventExtensions" title="en/Core
    JavaScript 1.5 Reference/Global Objects/Object/preventExtensions"><code>Object.preventExtensions</code></a></strong></li> <li><a href="/en/JavaScript/Reference/Global_Objects/Object/seal" title="en/Core
    JavaScript 1.5 Reference/Global Objects/Object/seal"><code>Object.seal</code></a></li> <li><a href="/en/JavaScript/Reference/Global_Objects/Object/isSealed" title="en/Core
    JavaScript 1.5 Reference/Global Objects/Object/isSealed"><code>Object.isSealed</code></a></li> <li><a href="/en/JavaScript/Reference/Global_Objects/Object/freeze" title="en/Core
    JavaScript 1.5 Reference/Global Objects/Object/freezed"><code>Object.freeze</code></a></li> <li><a href="/en/JavaScript/Reference/Global_Objects/Object/isFrozen" title="en/Core
    JavaScript 1.5 Reference/Global Objects/Object/isFrozen"><code>Object.isFrozen</code></a></li>
</ul>
Revert to this revision