mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-11 09:14:23 +08:00
128 lines
6.6 KiB
HTML
128 lines
6.6 KiB
HTML
<article id="wikiArticle">
|
||
<div></div>
|
||
<p><code><font face="Open Sans, Arial, sans-serif">静态方法 </font><strong>Reflect</strong></code><strong><code>.isExtensible()</code></strong> 判断一个对象是否可扩展 (即是否能够添加新的属性)。与它 <a href="Reference/Global_Objects/Object/isExtensible" title="Object.isExtensible() 方法判断一个对象是否是可扩展的(是否可以在它上面添加新的属性)。"><code>Object.isExtensible()</code></a> 方法相似,但有一些不同,详情可见 <a href="#Difference_to_Object.isExtensible()">differences</a>。</p>
|
||
<h2 id="语法">语法</h2>
|
||
<pre><code class="language-javascript">Reflect.isExtensible(target)
|
||
</code></pre>
|
||
<h3 id="参数">参数</h3>
|
||
<dl>
|
||
<dt><code>target</code></dt>
|
||
<dd>检查是否可扩展的目标对象。</dd>
|
||
</dl>
|
||
<h3 id="返回值">返回值</h3>
|
||
<p>返回一个 <a href="Reference/Boolean" title="此页面仍未被本地化, 期待您的翻译!"><code>Boolean</code></a> 值表明该对象是否可扩展。</p>
|
||
<h3 id="异常">异常</h3>
|
||
<p>抛出一个 <a href="Reference/Global_Objects/TypeError" title="TypeError(类型错误) 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a>,如果对象不是 <a href="Reference/Global_Objects/Object" title="Object 构造函数创建一个对象包装器。"><code>Object</code></a>。</p>
|
||
<h2 id="描述">描述</h2>
|
||
<p><code>Reflect.isExtensible 判断</code>一个对象是否可扩展 (即是否能够添加新的属性)。它与 <a href="Reference/Global_Objects/Object/isExtensible" title="Object.isExtensible() 方法判断一个对象是否是可扩展的(是否可以在它上面添加新的属性)。"><code>Object.isExtensible()</code></a> 方法一样。</p>
|
||
<h2 id="示例">示例</h2>
|
||
<h3 id="使用_Reflect.isExtensible()">使用 <code>Reflect.isExtensible()</code></h3>
|
||
<p>详情可见 <a href="Reference/Global_Objects/Object/isExtensible" title="Object.isExtensible() 方法判断一个对象是否是可扩展的(是否可以在它上面添加新的属性)。"><code>Object.isExtensible()</code></a>。</p>
|
||
<pre><code class="language-javascript">// New objects are extensible.
|
||
var empty = {};
|
||
Reflect.isExtensible(empty); // === true
|
||
|
||
// ...but that can be changed.
|
||
Reflect.preventExtensions(empty);
|
||
Reflect.isExtensible(empty); // === false
|
||
|
||
// Sealed objects are by definition non-extensible.
|
||
var sealed = Object.seal({});
|
||
Reflect.isExtensible(sealed); // === false
|
||
|
||
// Frozen objects are also by definition non-extensible.
|
||
var frozen = Object.freeze({});
|
||
Reflect.isExtensible(frozen); // === false
|
||
</code></pre>
|
||
<h3 id="与_Object.isExtensible()_的不同点">与 <code>Object.isExtensible() 的不同点</code></h3>
|
||
<p>如果该方法的第一个参数不是一个对象(原始值),那么将造成一个 <a href="Reference/Global_Objects/TypeError" title="TypeError(类型错误) 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a> 异常。对于 <a href="Reference/Global_Objects/Object/isExtensible" title="Object.isExtensible() 方法判断一个对象是否是可扩展的(是否可以在它上面添加新的属性)。"><code>Object.isExtensible()</code></a>,非对象的第一个参数会被强制转换为一个对象。</p>
|
||
<pre><code class="language-javascript">Reflect.isExtensible(1);
|
||
// TypeError: 1 is not an object
|
||
|
||
Object.isExtensible(1);
|
||
// false
|
||
</code></pre>
|
||
<h2 id="规范">规范</h2>
|
||
<table class="standard-table">
|
||
<tbody>
|
||
<tr>
|
||
<th scope="col">Specification</th>
|
||
<th scope="col">Status</th>
|
||
<th scope="col">Comment</th>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://www.ecma-international.org/ecma-262/6.0/#sec-reflect.isextensible" hreflang="en" lang="en" rel="noopener">ECMAScript 2015 (6th Edition, ECMA-262)<br/><small lang="zh-CN">Reflect.isExtensible</small></a></td>
|
||
<td><span class="spec-Standard">Standard</span></td>
|
||
<td>Initial definition.</td>
|
||
</tr>
|
||
<tr>
|
||
<td><a class="external" href="https://tc39.github.io/ecma262/#sec-reflect.isextensible" hreflang="en" lang="en" rel="noopener">ECMAScript Latest Draft (ECMA-262)<br/><small lang="zh-CN">Reflect.isExtensible</small></a></td>
|
||
<td><span class="spec-Draft">Draft</span></td>
|
||
<td> </td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<h2 id="浏览器兼容性">浏览器兼容性</h2>
|
||
<p></p><div class="blockIndicator warning"><strong><a class="external" href="https://github.com/mdn/browser-compat-data" rel="noopener">We're converting our compatibility data into a machine-readable JSON format</a></strong>.
|
||
This compatibility table still uses the old format,
|
||
because we haven't yet converted the data it contains.
|
||
<strong><a class="new" href="/zh-CN/docs/MDN/Contribute/Structures/Compatibility_tables" rel="nofollow">Find out how you can help!</a></strong></div>
|
||
<div class="htab">
|
||
<a id="AutoCompatibilityTable" name="AutoCompatibilityTable"></a>
|
||
<ul>
|
||
<li class="selected"><a>Desktop</a></li>
|
||
<li><a>Mobile</a></li>
|
||
</ul>
|
||
</div><p></p>
|
||
<div id="compat-desktop">
|
||
<table class="compat-table">
|
||
<tbody>
|
||
<tr>
|
||
<th>Feature</th>
|
||
<th>Chrome</th>
|
||
<th>Firefox (Gecko)</th>
|
||
<th>Internet Explorer</th>
|
||
<th>Opera</th>
|
||
<th>Safari</th>
|
||
</tr>
|
||
<tr>
|
||
<td>Basic support</td>
|
||
<td>49</td>
|
||
<td><a href="/en-US/Firefox/Releases/42" title="Released on 2015-11-03.">42</a> (42)</td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td>10</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<div id="compat-mobile">
|
||
<table class="compat-table">
|
||
<tbody>
|
||
<tr>
|
||
<th>Feature</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>Basic support</td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td>49</td>
|
||
<td>42.0 (42)</td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td><span style="color: #f00;">未实现</span></td>
|
||
<td>10</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<h2 id="相关链接">相关链接</h2>
|
||
<ul>
|
||
<li><a href="Reference/Global_Objects/Reflect" title="Reflect 是一个内置的对象,它提供拦截 JavaScript 操作的方法。这些方法与处理器对象的方法相同。Reflect不是一个函数对象,因此它是不可构造的。"><code>Reflect</code></a></li>
|
||
<li><a href="Reference/Global_Objects/Object/isExtensible" title="Object.isExtensible() 方法判断一个对象是否是可扩展的(是否可以在它上面添加新的属性)。"><code>Object.isExtensible()</code></a></li>
|
||
</ul>
|
||
</article> |