mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-16 07:51:52 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<div></div>
|
||||
<p><strong><code>Object.getOwnPropertyDescriptor()</code></strong> 方法返回指定对象上一个自有属性对应的属性描述符。(自有属性指的是直接赋予该对象的属性,不需要从原型链上进行查找的属性)</p>
|
||||
<h2 id="Syntax" name="Syntax">语法</h2>
|
||||
<pre class="syntaxbox">Object.getOwnPropertyDescriptor(<em>obj</em>, <em>prop</em>)</pre>
|
||||
<pre><code class="language-javascript">Object.getOwnPropertyDescriptor(<em>obj</em>, <em>prop</em>)</code></pre>
|
||||
<h3 id="Parameters" name="Parameters">参数</h3>
|
||||
<dl>
|
||||
<dt><code>obj</code></dt>
|
||||
@@ -30,7 +30,7 @@
|
||||
<dd>当且仅当指定对象的属性可以被枚举出时,为 <code>true</code>。</dd>
|
||||
</dl>
|
||||
<h2 id="Examples" name="Examples">示例</h2>
|
||||
<pre class="brush: js">var o, d;
|
||||
<pre><code class="language-javascript">var o, d;
|
||||
|
||||
o = { get foo() { return 17; } };
|
||||
d = Object.getOwnPropertyDescriptor(o, "foo");
|
||||
@@ -62,10 +62,10 @@ d = Object.getOwnPropertyDescriptor(o, "baz");
|
||||
// writable: false,
|
||||
// enumerable: false,
|
||||
// configurable: false
|
||||
// }</pre>
|
||||
// }</code></pre>
|
||||
<h2 id="注意事项">注意事项</h2>
|
||||
<p>在 ES5 中,如果该方法的第一个参数不是对象(而是原始类型),那么就会产生出现 <a href="Reference/Global_Objects/TypeError" title="TypeError(类型错误) 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a>。而在 ES2015,第一个的参数不是对象的话就会被强制转换为对象。</p>
|
||||
<pre class="brush: js">Object.getOwnPropertyDescriptor('foo', 0);
|
||||
<pre><code class="language-javascript">Object.getOwnPropertyDescriptor('foo', 0);
|
||||
// 类型错误: "foo" 不是一个对象 // ES5 code
|
||||
|
||||
Object.getOwnPropertyDescriptor('foo', 0);
|
||||
@@ -74,7 +74,7 @@ Object.getOwnPropertyDescriptor('foo', 0);
|
||||
// enumerable: true,
|
||||
// value: "f",
|
||||
// writable: false
|
||||
// }</pre>
|
||||
// }</code></pre>
|
||||
<h2 id="规范" style="margin-bottom: 20px; line-height: 30px;">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user