diff options
author | Irvin <irvinfly@gmail.com> | 2022-02-16 02:14:18 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2022-02-16 02:35:54 +0800 |
commit | d44f5032d0f53256b2d5aef505d6b593fd3cd158 (patch) | |
tree | 4b585f4be9c9a2712664ad10e7acf62c83fff51f /files/zh-cn/web/javascript/reference/global_objects/object | |
parent | f45e9e070c93ebbd83d488bdd775987a4d75c201 (diff) | |
download | translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.tar.gz translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.tar.bz2 translated-content-d44f5032d0f53256b2d5aef505d6b593fd3cd158.zip |
fix yari h2m dry run errors (zh-CN)
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/object')
19 files changed, 50 insertions, 337 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/__definegetter__/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/__definegetter__/index.html index b0229c493e..d8fb71db90 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/__definegetter__/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/__definegetter__/index.html @@ -47,55 +47,11 @@ console.log(o.gimmeFive); // 5 </pre> <h2 id="Specifications">规范</h2> <p>不属于任何规范。</p> -<h2 id="Browser_compatibility">浏览器兼容性</h2> -<div> - {{CompatibilityTable}}</div> -<div> - <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>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatIE("11")}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> - </table> -</div> -<div> - <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>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> - </table> -</div> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +{{Compat}} + <h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.__defineSetter__()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/__definesetter__/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/__definesetter__/index.html index b854a96ea0..519bedad8e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/__definesetter__/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/__definesetter__/index.html @@ -32,55 +32,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__ <p><code>__defineSetter__</code> 方法可以为一个已经存在的对象设置(新建或修改)访问器属性,而 {{jsxref("Operators/set", "对象字面量中的 set 语法", "", 1)}} 只能在新建一个对象时使用。</p> <h2 id="Specifications">规范</h2> <p>不属于任何规范。</p> -<h2 id="Browser_compatibility">浏览器兼容性</h2> -<div> - {{CompatibilityTable}}</div> -<div> - <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>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatIE("11")}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> - </table> -</div> -<div> - <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>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> - </table> -</div> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +{{Compat}} + <h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.__defineGetter__()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/__lookupgetter__/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/__lookupgetter__/index.html index 52fe502257..5c722986ef 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/__lookupgetter__/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/__lookupgetter__/index.html @@ -59,55 +59,7 @@ Object.getOwnPropertyDescriptor(prototype, "foo").get <h2 id="浏览器兼容性">浏览器兼容性</h2> -<p>{{ CompatibilityTable() }}</p> - -<div> -<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>{{CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{CompatVersionUnknown() }}</td> - <td>{{CompatVersionUnknown() }}</td> - </tr> - </tbody> -</table> -</div> - -<div> -<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>{{CompatVersionUnknown() }}</td> - <td>{{CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{ CompatUnknown() }}</td> - <td>{{CompatVersionUnknown() }}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="See_also">相关链接</h2> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/__lookupsetter__/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/__lookupsetter__/index.html index 859318a8bc..db8cff8eba 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/__lookupsetter__/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/__lookupsetter__/index.html @@ -77,55 +77,7 @@ Object.getOwnPropertyDescriptor(obj, 'foo').set; <h2 id="浏览器兼容性">浏览器兼容性</h2> -<div>{{CompatibilityTable}}</div> - -<div> -<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>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatIE("11")}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div> -<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>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="相关链接">相关链接</h2> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html index c81cacda30..4b8696d2ab 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html @@ -45,8 +45,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign <p>在出现错误的情况下,例如,如果属性不可写,会引发{{jsxref("TypeError")}},如果在引发错误之前添加了任何属性,则可以更改<code>target</code>对象。</p> -<div class="blockIndicator note"> -<p>注意,<code>Object.assign</code> 不会在那些<code>source</code>对象值为 {{jsxref("null")}} 或 {{jsxref("undefined")}} 的时候抛出错误。</p> +<div class="note"> + <p><strong>备注:</strong> <code>Object.assign</code> 不会在那些<code>source</code>对象值为 {{jsxref("null")}} 或 {{jsxref("undefined")}} 的时候抛出错误。</p> </div> <h2 id="Polyfill_2">Polyfill</h2> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html index 74b6088e27..6e3f75cea7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html @@ -43,7 +43,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperty <p>被传递给函数的对象。</p> <div class="note"> -<p>在ES6中,由于 Symbol类型的特殊性,用Symbol类型的值来做对象的key与常规的定义或修改不同,而<code>Object.defineProperty</code> 是定义key为Symbol的属性的方法之一。</p> +<p><strong>备注:</strong>在ES6中,由于 Symbol类型的特殊性,用Symbol类型的值来做对象的key与常规的定义或修改不同,而<code>Object.defineProperty</code> 是定义key为Symbol的属性的方法之一。</p> </div> <h2 id="描述">描述</h2> @@ -94,9 +94,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperty <h4 id="描述符可拥有的键值">描述符可拥有的键值</h4> -<dl> - <dt> - <table class="standard-table"> +<table class="standard-table"> <caption></caption> <tbody> <tr> @@ -128,8 +126,6 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperty </tr> </tbody> </table> - </dt> -</dl> <p>如果一个描述符不具有 <code>value</code>、<code>writable</code>、<code>get</code> 和 <code>set</code> 中的任意一个键,那么它将被认为是一个数据描述符。如果一个描述符同时拥有 <code>value</code> 或 <code>writable</code> 和 <code>get</code> 或 <code>set</code> 键,则会产生一个异常。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/entries/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/entries/index.html index ee59ebba46..db3fac1a89 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/entries/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/entries/index.html @@ -29,9 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/entries <h3 id="返回值">返回值</h3> -<dl> - <dd>给定对象自身可枚举属性的键值对数组。</dd> -</dl> +<p>给定对象自身可枚举属性的键值对数组。</p> <h2 id="描述">描述</h2> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/freeze/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/freeze/index.html index 6237badeea..6cc6d1c17a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/freeze/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/freeze/index.html @@ -86,7 +86,7 @@ Object.defineProperty(obj, 'foo', { value: 'eit' }); Object.setPrototypeOf(obj, { x: 20 }) obj.__proto__ = { x: 20 }</pre> -<h3 class="brush: js" id="冻结数组">冻结数组</h3> +<h3 id="冻结数组">冻结数组</h3> <pre class="brush: js">let a = [0]; Object.freeze(a); // 现在数组不能被修改了. diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html index 22df48a042..52875fee26 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html @@ -41,7 +41,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes <p>创建子类的典型方法是定义子类,将其原型设置为超类的实例,然后在该实例上定义属性。这么写很不优雅,特别是对于 getters 和 setter 而言。 相反,您可以使用此代码设置原型:</p> -<pre class="brush: js line-numbers language-js">function superclass() {} +<pre class="brush: js">function superclass() {} superclass.prototype = { // 在这里定义方法和属性 }; diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertysymbols/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertysymbols/index.html index f763ec6856..ef1b0ba509 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertysymbols/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertysymbols/index.html @@ -21,12 +21,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySym <dl> <dt><code>obj</code></dt> <dd>要返回 Symbol 属性的对象。</dd> - <dt> - <h3 id="返回值">返回值</h3> - </dt> - <dd>在给定对象自身上找到的所有 Symbol 属性的数组。</dd> </dl> +<h3 id="返回值">返回值</h3> + +<p>在给定对象自身上找到的所有 Symbol 属性的数组。</p> + <h2 id="Description">描述</h2> <p>与{{jsxref("Object.getOwnPropertyNames()")}}类似,您可以将给定对象的所有符号属性作为 Symbol 数组获取。 请注意,{{jsxref("Object.getOwnPropertyNames()")}}本身不包含对象的 Symbol 属性,只包含字符串属性。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getprototypeof/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getprototypeof/index.html index ae9a9e5866..a7f274bbfa 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/getprototypeof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/getprototypeof/index.html @@ -17,16 +17,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf <pre class="syntaxbox"><code>Object.getPrototypeOf(<em>object</em>)</code> </pre> -<dl> - <dt> - <h3 id="参数">参数<code>obj</code></h3> - </dt> - <dd>要返回其原型的对象。</dd> - <dt> - <h3 id="返回值">返回值</h3> - </dt> - <dd>给定对象的原型。如果没有继承属性,则返回 {{jsxref("null")}} 。</dd> -</dl> +<h3 id="参数">参数<code>obj</code></h3> + +<p>要返回其原型的对象。</p> + +<h3 id="返回值">返回值</h3> + +<p>给定对象的原型。如果没有继承属性,则返回 {{jsxref("null")}} 。</p> <p>{{EmbedInteractiveExample("pages/js/object-getprototypeof.html")}}</p> @@ -42,7 +39,7 @@ Object.getPrototypeOf(reg) === RegExp.prototype; // true</pre> <h3 id="说明">说明</h3> <div class="note"> -<p><strong>Object.getPrototypeOf(Object) 不是 Object.prototype</strong></p> +<p><strong>备注:</strong></p> </div> <pre class="brush: js">JavaScript中的 <strong><a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object">Object</a></strong> 是构造函数(创建对象的包装器)。 diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/isextensible/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/isextensible/index.html index 1a515b96ff..460aa64a98 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/isextensible/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/isextensible/index.html @@ -85,53 +85,7 @@ Object.isExtensible(1); <h2 id="浏览器兼容性">浏览器兼容性</h2> -<div>{{CompatibilityTable}}</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Firefox (Gecko)</th> - <th>Chrome</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>4 (2.0)</td> - <td>6</td> - <td>9</td> - <td>12</td> - <td>5.1</td> - </tr> - </tbody> -</table> -</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Firefox Mobile (Gecko)</th> - <th>Android</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="See_also">相关链接</h2> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/isfrozen/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/isfrozen/index.html index cc428900b0..bb57973679 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/isfrozen/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/isfrozen/index.html @@ -22,12 +22,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isFrozen <dl> <dt><code>obj</code></dt> <dd>被检测的对象。</dd> - <dt> - <h3 id="返回值">返回值</h3> - </dt> - <dd>表示给定对象是否被冻结的{{jsxref("Boolean")}}。</dd> </dl> +<h3 id="返回值">返回值</h3> + +<p>表示给定对象是否被冻结的{{jsxref("Boolean")}}。</p> + <h2 id="Description">描述</h2> <p>一个对象是冻结的是指它不可{{jsxref("Object.isExtensible", "扩展")}},所有属性都是不可配置的,且所有数据属性(即没有getter或setter组件的访问器的属性)都是不可写的。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/isprototypeof/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/isprototypeof/index.html index fb360e1ec1..98bef633c7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/isprototypeof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/isprototypeof/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf <p><code><strong>isPrototypeOf()</strong></code> 方法用于测试一个对象是否存在于另一个对象的原型链上。</p> <div class="note"> -<p><code>isPrototypeOf()</code> 与 {{jsxref("Operators/instanceof", "instanceof")}} 运算符不同。在表达式 "<code>object instanceof AFunction</code>"中,<code>object</code> 的原型链是针对 <code>AFunction.prototype</code> 进行检查的,而不是针对 <code>AFunction</code> 本身。</p> +<p><strong>备注:</strong><code>isPrototypeOf()</code> 与 {{jsxref("Operators/instanceof", "instanceof")}} 运算符不同。在表达式 "<code>object instanceof AFunction</code>"中,<code>object</code> 的原型链是针对 <code>AFunction.prototype</code> 进行检查的,而不是针对 <code>AFunction</code> 本身。</p> </div> <h2 id="语法">语法</h2> @@ -107,57 +107,7 @@ console.log(Object.prototype.isPrototypeOf(baz)); // true <h2 id="浏览器兼容性">浏览器兼容性</h2> -<div>{{CompatibilityTable}}</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>特性</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>基础支持</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - </tr> - </tbody> -</table> -</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>特性</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>基础支持</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - <td>{{ CompatVersionUnknown() }}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="相关链接">相关链接</h2> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/preventextensions/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/preventextensions/index.html index 09c0ff1c1a..72fb597281 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/preventextensions/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/preventextensions/index.html @@ -23,12 +23,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/preventExtensions <dl> <dt><code>obj</code></dt> <dd>将要变得不可扩展的对象。</dd> - <dt> - <h3 id="返回值">返回值</h3> - </dt> - <dd>已经不可扩展的对象。</dd> </dl> +<h3 id="返回值">返回值</h3> + +<p>已经不可扩展的对象。</p> + <h2 id="Description">描述</h2> <p>如果一个对象可以添加新的属性,则这个对象是可扩展的。<code>Object.preventExtensions()</code>将对象标记为不再可扩展,这样它将永远不会具有它被标记为不可扩展时持有的属性之外的属性。注意,一般来说,不可扩展对象的属性可能仍然可被<em>删除</em>。尝试将新属性添加到不可扩展对象将静默失败或抛出{{jsxref("TypeError")}}(最常见的情况是{{jsxref("Functions_and_function_scope/Strict_mode", "strict mode", "", 1)}}中,但不排除其他情况)。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/proto/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/proto/index.html index d0ac7d3eb6..90f9790a0b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/proto/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/proto/index.html @@ -13,11 +13,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/proto <div>{{JSRef}}{{Deprecated_header}}</div> <div class="warning"> -<p><strong>警告:</strong> 通过现代浏览器的操作属性的便利性,可以改变一个对象的 <code>[[Prototype]]</code> 属性, 这种行为在每一个JavaScript引擎和浏览器中都是一个非常慢且影响性能的操作,使用这种方式来改变和继承属性是对性能影响非常严重的,并且性能消耗的时间也不是简单的花费在 <code>obj.__proto__ = ...</code> 语句上, 它还会影响到所有继承来自该 <code>[[Prototype]]</code> 的对象,如果你关心性能,你就不应该在一个对象中修改它的 [[Prototype]]。相反, 创建一个新的且可以继承 <code>[[Prototype]]</code> 的对象,推荐使用 {{jsxref("Object.create()")}}。</p> +<p><strong>警告:</strong>通过现代浏览器的操作属性的便利性,可以改变一个对象的 <code>[[Prototype]]</code> 属性, 这种行为在每一个JavaScript引擎和浏览器中都是一个非常慢且影响性能的操作,使用这种方式来改变和继承属性是对性能影响非常严重的,并且性能消耗的时间也不是简单的花费在 <code>obj.__proto__ = ...</code> 语句上, 它还会影响到所有继承来自该 <code>[[Prototype]]</code> 的对象,如果你关心性能,你就不应该在一个对象中修改它的 [[Prototype]]。相反, 创建一个新的且可以继承 <code>[[Prototype]]</code> 的对象,推荐使用 {{jsxref("Object.create()")}}。</p> </div> <div class="warning"> -<p><strong>警告:</strong> 当<code>Object.prototype.__proto__</code> 已被大多数浏览器厂商所支持的今天,其存在和确切行为仅在ECMAScript 2015规范中被标准化为传统功能,以确保Web浏览器的兼容性。为了更好的支持,建议只使用 {{jsxref("Object.getPrototypeOf()")}}。</p> +<p><strong>警告:</strong>当<code>Object.prototype.__proto__</code> 已被大多数浏览器厂商所支持的今天,其存在和确切行为仅在ECMAScript 2015规范中被标准化为传统功能,以确保Web浏览器的兼容性。为了更好的支持,建议只使用 {{jsxref("Object.getPrototypeOf()")}}。</p> </div> <div>{{jsxref("Object.prototype")}} 的 <code>__proto__</code> 属性是一个访问器属性(一个getter函数和一个setter函数), 暴露了通过它访问的对象的内部<code>[[Prototype]]</code> (一个对象或 {{jsxref("Global_Objects/null", "null")}})。</div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/setprototypeof/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/setprototypeof/index.html index 06de1bcc7c..a73a8c612c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/setprototypeof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/setprototypeof/index.html @@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf <div></div> <div class="warning"> -<p><strong>警告:</strong> 由于现代 JavaScript 引擎优化属性访问所带来的特性的关系,更改对象的 <code>[[Prototype]]</code>在<em><strong>各个</strong></em>浏览器和 JavaScript 引擎上都是一个很慢的操作。其在更改继承的性能上的影响是微妙而又广泛的,这不仅仅限于 <code>obj.__proto__ = ...</code> 语句上的时间花费,而且可能会延伸到<em><strong>任何</strong></em>代码,那些可以访问<em><strong>任何</strong></em><code>[[Prototype]]</code>已被更改的对象的代码。如果你关心性能,你应该避免设置一个对象的 <code>[[Prototype]]</code>。相反,你应该使用 {{jsxref("Object.create()")}}来创建带有你想要的<code>[[Prototype]]</code>的新对象。</p> +<p><strong>警告:</strong>由于现代 JavaScript 引擎优化属性访问所带来的特性的关系,更改对象的 <code>[[Prototype]]</code>在<em><strong>各个</strong></em>浏览器和 JavaScript 引擎上都是一个很慢的操作。其在更改继承的性能上的影响是微妙而又广泛的,这不仅仅限于 <code>obj.__proto__ = ...</code> 语句上的时间花费,而且可能会延伸到<em><strong>任何</strong></em>代码,那些可以访问<em><strong>任何</strong></em><code>[[Prototype]]</code>已被更改的对象的代码。如果你关心性能,你应该避免设置一个对象的 <code>[[Prototype]]</code>。相反,你应该使用 {{jsxref("Object.create()")}}来创建带有你想要的<code>[[Prototype]]</code>的新对象。</p> </div> <h2 id="Syntax">语法</h2> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/tostring/index.html index 55310e85b0..23b9e41248 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/tostring/index.html @@ -35,7 +35,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/toString o.toString(); // 返回 [object Object] </pre> -<div class="note"><strong>注意:</strong>如 ECMAScript 5 和随后的 Errata 中所定义,从 JavaScript 1.8.5 开始,<code>toString()</code> 调用 {{jsxref("null")}} 返回<code>[object <em>Null</em>]</code>,{{jsxref("undefined")}} 返回 <code>[object Undefined]</code>。请参阅下面的{{anch("Using_toString()_to_detect_object_class", "使用 <code>toString()</code> 检测对象类型")}}。</div> +<div class="note"> +<p><strong>备注:</strong>如 ECMAScript 5 和随后的 Errata 中所定义,从 JavaScript 1.8.5 开始,<code>toString()</code> 调用 {{jsxref("null")}} 返回<code>[object <em>Null</em>]</code>,{{jsxref("undefined")}} 返回 <code>[object Undefined]</code>。请参阅下面的{{anch("Using_toString()_to_detect_object_class", "使用 <code>toString()</code> 检测对象类型")}}。</p> +</div> <h2 id="示例">示例</h2> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html index 6280feeb05..3fa248c3c5 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html @@ -88,7 +88,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/valueOf <pre class="brush: js">myNumberType.valueOf()</pre> <div class="note"> -<p><strong>注意:</strong>字符串上下文中的对象通过 {{jsxref("Object.toString", "toString()")}}方法转换,这与使用<code>valueOf</code>转换为原始字符串的{{jsxref("String")}}对象不同。所有对象都能转换成一个“<code>[object <em>类型</em>]</code>”这种格式的字符串。但是很多对象不能转换为数字,布尔或函数。</p> +<p><strong>备注:</strong>字符串上下文中的对象通过 {{jsxref("Object.toString", "toString()")}}方法转换,这与使用<code>valueOf</code>转换为原始字符串的{{jsxref("String")}}对象不同。所有对象都能转换成一个“<code>[object <em>类型</em>]</code>”这种格式的字符串。但是很多对象不能转换为数字,布尔或函数。</p> </div> <h2 id="示例">示例</h2> @@ -147,7 +147,7 @@ console.log( str2.valueOf() === str2 ); // false</pre> <h3 id="改写_.prototype.valueof">改写 .prototype.valueof</h3> -<pre class="brush: js line-numbers language-js">function MyNumberType(n) { +<pre class="brush: js">function MyNumberType(n) { this.number = n; } |