aboutsummaryrefslogtreecommitdiff
path: root/files/ca/web/javascript/reference/global_objects/object/isextensible
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:41:15 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:41:15 -0500
commit4b1a9203c547c019fc5398082ae19a3f3d4c3efe (patch)
treed4a40e13ceeb9f85479605110a76e7a4d5f3b56b /files/ca/web/javascript/reference/global_objects/object/isextensible
parent33058f2b292b3a581333bdfb21b8f671898c5060 (diff)
downloadtranslated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.gz
translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.tar.bz2
translated-content-4b1a9203c547c019fc5398082ae19a3f3d4c3efe.zip
initial commit
Diffstat (limited to 'files/ca/web/javascript/reference/global_objects/object/isextensible')
-rw-r--r--files/ca/web/javascript/reference/global_objects/object/isextensible/index.html138
1 files changed, 138 insertions, 0 deletions
diff --git a/files/ca/web/javascript/reference/global_objects/object/isextensible/index.html b/files/ca/web/javascript/reference/global_objects/object/isextensible/index.html
new file mode 100644
index 0000000000..7b8700654c
--- /dev/null
+++ b/files/ca/web/javascript/reference/global_objects/object/isextensible/index.html
@@ -0,0 +1,138 @@
+---
+title: Object.isExtensible()
+slug: Web/JavaScript/Reference/Global_Objects/Object/isExtensible
+translation_of: Web/JavaScript/Reference/Global_Objects/Object/isExtensible
+---
+<div>{{JSRef}}</div>
+
+<p>El mètode <strong><code>Object.isExtensible()</code></strong> determina si un objecte és extensible (és a dir, si accepta l'addició de noves propietats).</p>
+
+<h2 id="Sintaxi">Sintaxi</h2>
+
+<pre class="syntaxbox"><code>Object.isExtensible(<var>obj</var>)</code></pre>
+
+<h3 id="Paràmetres">Paràmetres</h3>
+
+<dl>
+ <dt><code>obj</code></dt>
+ <dd>L'objecte del que comprovarà l'extensibilitat.</dd>
+</dl>
+
+<h2 id="Descripció">Descripció</h2>
+
+<p>Per defecte tots els objectes són extensibles: se'ls hi poden afegir noves propietats, i (en objectes que suportin {{jsxref("Object.proto", "__proto__")}} {{deprecated_inline}} la seva propietat __proto__ property) es pot modificar. Es pot marcar un objecte com a no extensible utilitzant {{jsxref("Object.preventExtensions()")}}, {{jsxref("Object.seal()")}}, o bé {{jsxref("Object.freeze()")}}.</p>
+
+<h2 id="Exemples">Exemples</h2>
+
+<pre class="brush: js">// Els objectes nous són extensibles.
+var empty = {};
+Object.isExtensible(empty); // === true
+
+// ...pero això pot canviar.
+Object.preventExtensions(empty);
+Object.isExtensible(empty); // === false
+
+// Els objectes segellats són no extensibles per definició
+var sealed = Object.seal({});
+Object.isExtensible(sealed); // === false
+
+// Els objectes congelats també són no extensibes per definició
+var frozen = Object.freeze({});
+Object.isExtensible(frozen); // === false
+</pre>
+
+<h2 id="Notes">Notes</h2>
+
+<p>A l'EcmaScript 5, si l'argument d'aquest mètode no és un objecte (un valor primitiu) es llençarà una excepció {{jsxref("TypeError")}}. A l'EcmaScript 6, un argument que no sigui un objecte es tractarà com si fós un objecte no extensible ordinari i simplement retornarà <code>false</code>.</p>
+
+<pre class="brush: js">Object.isExtensible(1);
+// TypeError: 1 no és un objecte (codi EcmaScript 5)
+
+Object.isExtensible(1);
+// false (codi EcmaScript 6)
+</pre>
+
+<h2 id="Especificacions">Especificacions</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Especificació</th>
+ <th scope="col">Estat</th>
+ <th scope="col">Comentaris</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES5.1', '#sec-15.2.3.13', 'Object.isExtensible')}}</td>
+ <td>{{Spec2('ES5.1')}}</td>
+ <td>Definició inicial. Implementat a JavaScript 1.8.5.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('ES6', '#sec-object.isextensible', 'Object.isExtensible')}}</td>
+ <td>{{Spec2('ES6')}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Compatibilitat_amb_navegadors">Compatibilitat amb navegadors</h2>
+
+<div>{{CompatibilityTable}}</div>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari</th>
+ </tr>
+ <tr>
+ <td>Suport bàsic</td>
+ <td>{{CompatChrome("6")}}</td>
+ <td>{{CompatGeckoDesktop("2.0")}}</td>
+ <td>{{CompatIE("9")}}</td>
+ <td>{{CompatOpera("12")}}</td>
+ <td>{{CompatSafari("5.1")}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Característica</th>
+ <th>Android</th>
+ <th>Chrome for Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Mobile</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Suport bàsic</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatUnknown}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<h2 id="Vegeu_també">Vegeu també</h2>
+
+<ul>
+ <li>{{jsxref("Object.preventExtensions()")}}</li>
+ <li>{{jsxref("Object.seal()")}}</li>
+ <li>{{jsxref("Object.isSealed()")}}</li>
+ <li>{{jsxref("Object.freeze()")}}</li>
+ <li>{{jsxref("Object.isFrozen()")}}</li>
+ <li>{{jsxref("Reflect.isExtensible()")}}</li>
+</ul>