diff options
author | t7yang <t7yang@gmail.com> | 2022-01-10 08:38:07 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2022-02-16 02:35:54 +0800 |
commit | c40612041809fe289aba58aefa170bbe784aba1f (patch) | |
tree | 8ca89b071d04afcf7abd6d9a04d0765a041d9c8a /files/zh-cn/web/javascript/reference/global_objects | |
parent | 12a899ab8540bc84f56a0dc6491be80a48499d49 (diff) | |
download | translated-content-c40612041809fe289aba58aefa170bbe784aba1f.tar.gz translated-content-c40612041809fe289aba58aefa170bbe784aba1f.tar.bz2 translated-content-c40612041809fe289aba58aefa170bbe784aba1f.zip |
remove name attribute for zh-CN
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects')
234 files changed, 1116 insertions, 1116 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html index b0960c35d0..dbd74c0909 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/concat/index.html @@ -18,7 +18,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat <pre class="syntaxbox">var <var>new_array</var> = <var>old_array</var>.concat(<var>value1</var>[, <var>value2</var>[, ...[, <var>valueN</var>]]])</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value<em>N</em></code>{{optional_inline}}</dt> @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat <p>新的 {{jsxref("Array")}} 实例。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>concat</code>方法创建一个新的数组,它由被调用的对象中的元素组成,每个参数的顺序依次是该参数的元素(如果参数是数组)或参数本身(如果参数不是数组)。它不会递归到嵌套数组参数中。</p> @@ -47,9 +47,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat <p><strong>注意:</strong>数组/值在连接时保持不变。此外,对于新数组的任何操作(仅当元素不是对象引用时)都不会对原始数组产生影响,反之亦然。</p> </div> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Concatenating_two_arrays" name="Example:_Concatenating_two_arrays">连接两个数组</h3> +<h3 id="Example_Concatenating_two_arrays">连接两个数组</h3> <p>以下代码将两个数组合并为一个新数组:</p> @@ -59,7 +59,7 @@ var numeric = [1, 2, 3]; alpha.concat(numeric); // result in ['a', 'b', 'c', 1, 2, 3]</pre> -<h3 id="Example_Concatenating_three_arrays" name="Example:_Concatenating_three_arrays">连接三个数组</h3> +<h3 id="Example_Concatenating_three_arrays">连接三个数组</h3> <p>以下代码将三个数组合并为一个新数组:</p> @@ -72,7 +72,7 @@ var nums = num1.concat(num2, num3); console.log(nums); // results in [1, 2, 3, 4, 5, 6, 7, 8, 9]</pre> -<h3 id="Example_Concatenating_values_to_an_array" name="Example:_Concatenating_values_to_an_array">将值连接到数组</h3> +<h3 id="Example_Concatenating_values_to_an_array">将值连接到数组</h3> <p>以下代码将三个值连接到数组:</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/copywithin/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/copywithin/index.html index b19fa2fc56..63436145d7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/copywithin/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/copywithin/index.html @@ -23,7 +23,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/copyWithin <pre class="syntaxbox"><var>arr</var>.copyWithin(<var>target[</var>, <var>start[</var>, <var>end]]</var>) </pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>target</code></dt> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/fill/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/fill/index.html index 07c1c104b5..0b7cdccee9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/fill/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/fill/index.html @@ -15,11 +15,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/fill <p>{{EmbedInteractiveExample("pages/js/array-fill.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre><var>arr</var>.fill(<var>value[</var>, <var>start[<var>, <var>end]]</var>)</var></var></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value</code></dt> @@ -34,7 +34,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/fill <p>修改后的数组。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><strong><code>fill</code></strong> 方法接受三个参数 <code>value</code>, <code>start</code> 以及 <code>end</code>. <code>start</code> 和 <code>end</code> 参数是可选的, 其默认值分别为 <code>0</code> 和 <code>this</code> 对象的 <code>length </code>属性值。</p> @@ -145,7 +145,7 @@ arr[0].hi = "hi"; // [{ hi: "hi" }, { hi: "hi" }, { hi: "hi" }]</pre> </div> -<h2 id="See_also" name="See_also">相关</h2> +<h2 id="See_also">相关</h2> <ul> <li>{{jsxref("Array")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/find/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/find/index.html index 425901f14d..ee5ad032da 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/find/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/find/index.html @@ -19,11 +19,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/find <p>如果你需要找到一个元素的位置或者一个元素是否存在于数组中,使用{{jsxref("Array.prototype.indexOf()")}} 或 {{jsxref("Array.prototype.includes()")}}。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>arr</em>.find(<em>callback</em>[, <em>thisArg</em>])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>callback</code></dt> @@ -45,7 +45,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/find <p>数组中第一个满足所提供测试函数的元素的值,否则返回 {{jsxref("undefined")}}。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>find</code>方法对数组中的每一项元素执行一次 <code>callback</code> 函数,直至有一个 callback 返回 <code>true</code>。当找到了这样一个元素后,该方法会立即返回这个元素的值,否则返回 {{jsxref("undefined")}}。注意 <code>callback </code>函数会为数组中的每个索引调用即从 <code>0 </code>到 <code>length - 1</code>,而不仅仅是那些被赋值的索引,这意味着对于稀疏数组来说,该方法的效率要低于那些只遍历有值的索引的方法。</p> @@ -114,7 +114,7 @@ a.find(function(value, index) { console.log('Visited index ' + index + ' with value ' + value); });</pre> -<h2 id="Polyfill" name="Polyfill">Polyfill</h2> +<h2 id="Polyfill">Polyfill</h2> <p>本方法在ECMAScript 6规范中被加入,可能不存在于某些实现中。你可以通过以下代码来补充 <code>Array.prototype.find()</code>。</p> @@ -189,7 +189,7 @@ if (!Array.prototype.find) { <p>{{Compat("javascript.builtins.Array.find")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.findIndex()")}} – find and return an index</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html index ecde3c0f25..39faf1fdf3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/findindex/index.html @@ -18,11 +18,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex <p>另请参见 {{jsxref("Array.find", "find()")}} 方法,它返回数组中找到的元素的<strong>值</strong>,而不是其索引。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>arr</em>.findIndex(<em>callback</em>[, <em>thisArg</em>])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>callback</code></dt> @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex <p> 数组中通过提供测试函数的第一个元素的<strong>索引</strong>。否则,返回-1</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>findIndex</code>方法对数组中的每个数组索引<code>0..length-1</code>(包括)执行一次<code>callback</code>函数,直到找到一个<code>callback</code>函数返回真实值(强制为<code>true</code>)的值。如果找到这样的元素,<code>findIndex</code>会立即返回该元素的索引。如果回调从不返回真值,或者数组的<code>length</code>为0,则<code>findIndex</code>返回-1。 与某些其他数组方法(如Array#some)不同,在稀疏数组中,即使对于数组中不存在的条目的索引也会调用回调函数。</p> @@ -56,9 +56,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex <p>在第一次调用<code>callback</code>函数时会确定元素的索引范围,因此在<code>findIndex</code>方法开始执行之后添加到数组的新元素将不会被<code>callback</code>函数访问到。如果数组中一个尚未被<code>callback</code>函数访问到的元素的值被<code>callback</code>函数所改变,那么当<code>callback</code>函数访问到它时,它的值是将是根据它在数组中的索引所访问到的当前值。被删除的元素仍然会被访问到。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Testing_size_of_all_array_elements" name="Example:_Testing_size_of_all_array_elements">查找数组中首个质数元素的索引</h3> +<h3 id="Example_Testing_size_of_all_array_elements">查找数组中首个质数元素的索引</h3> <p>以下示例查找数组中素数的元素的索引(如果不存在素数,则返回-1)。</p> @@ -153,7 +153,7 @@ if (!Array.prototype.findIndex) { <p>{{Compat("javascript.builtins.Array.findIndex")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.find()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/indexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/indexof/index.html index c470a8b265..a4ef7ead3b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/indexof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/indexof/index.html @@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/indexOf <p>注意:对于String方法,请参阅 {{jsxref("String.prototype.indexOf()")}}。</p> </div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre><var>arr</var>.indexOf(<var>searchElement</var>[, <var>fromIndex</var>])</pre> @@ -189,7 +189,7 @@ if (!Array.prototype.indexOf) { <p>{{Compat("javascript.builtins.Array.indexOf")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.lastIndexOf()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/join/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/join/index.html index c40b87ebed..b4c06b6acb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/join/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/join/index.html @@ -14,11 +14,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join <div>{{EmbedInteractiveExample("pages/js/array-join.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre><var>arr</var>.join([<var>separator</var>])</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>separator</code> {{optional_inline}}</dt> @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join <dd>一个所有数组元素连接的字符串。如果 <code>arr.length</code><strong> </strong>为0,则返回空字符串。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>所有的数组元素被转换成字符串,再用一个分隔符将这些字符串连接起来。</p> @@ -37,9 +37,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join <p>如果一个元素为 <code>undefined</code> 或 <code>null</code>,它会被转换为空字符串。</p> </div> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Joining_an_array_three_different_ways" name="Example:_Joining_an_array_three_different_ways">使用四种不同的分隔符连接数组元素</h3> +<h3 id="Example_Joining_an_array_three_different_ways">使用四种不同的分隔符连接数组元素</h3> <p>下例首先创建了一个数组 <code>a</code>,包含有三个元素,然后用四种不同的分隔符连接所有数组元素。首先是默认的分隔符逗号,然后是一个逗号加空格,接下来是一个加号前后加空格,最后是一个空字符串。</p> @@ -60,7 +60,7 @@ var myVar4 = a.join(''); // myVar4的值变为"WindRainFire" } f(1, 'a', true);</code></pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -92,7 +92,7 @@ f(1, 'a', true);</code></pre> </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> <div> @@ -102,7 +102,7 @@ f(1, 'a', true);</code></pre> </div> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("String.prototype.split()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/keys/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/keys/index.html index 6da9228ed2..b8e10fdada 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/keys/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/keys/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/keys <div>{{EmbedInteractiveExample("pages/js/array-keys.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>arr</var>.keys()</code> </pre> @@ -25,7 +25,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/keys <p>一个新的 {{jsxref("Array")}} 迭代器对象。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="索引迭代器会包含那些没有对应元素的索引">索引迭代器会包含那些没有对应元素的索引</h3> @@ -36,7 +36,7 @@ console.log(sparseKeys); // ['0', '2'] console.log(denseKeys); // [0, 1, 2] </pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -58,7 +58,7 @@ console.log(denseKeys); // [0, 1, 2] </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> <div> @@ -68,7 +68,7 @@ console.log(denseKeys); // [0, 1, 2] </div> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.values()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html index 51cf89a71f..8d3c63aab0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/lastindexof/index.html @@ -5,17 +5,17 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf --- <div>{{JSRef("Global_Objects", "Array")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>lastIndexOf()</strong></code> 方法返回指定元素(也即有效的 JavaScript 值或变量)在数组中的最后一个的索引,如果不存在则返回 -1。从数组的后面向前查找,从 <code>fromIndex</code> 处开始。</p> <div>{{EmbedInteractiveExample("pages/js/array-lastindexof.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre><var>arr</var>.lastIndexOf(<var>searchElement[</var>, <var>fromIndex]</var>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>searchElement</code></dt> @@ -29,13 +29,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf </dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>lastIndexOf</code> 使用<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Comparison_Operators#Using_the_Equality_Operators">严格相等</a>(strict equality,即 ===)比较 <code>searchElement</code> 和数组中的元素。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_lastIndexOf" name="Example:_Using_lastIndexOf">例子:使用 lastIndexOf</h3> +<h3 id="Example_Using_lastIndexOf">例子:使用 lastIndexOf</h3> <p>下例使用 <code>lastIndexOf</code> 定位数组中的值。</p> @@ -54,7 +54,7 @@ index = array.lastIndexOf(2, -1); // index is 3 </pre> -<h3 id="Example_Finding_all_the_occurrences_of_an_element" name="Example:_Finding_all_the_occurrences_of_an_element">例子:查找所有元素</h3> +<h3 id="Example_Finding_all_the_occurrences_of_an_element">例子:查找所有元素</h3> <p>下例使用 <code>lastIndexOf</code> 查找到一个元素在数组中所有的索引(下标),并使用 {{jsxref("Array.push", "push")}} 将所有添加到另一个数组中。</p> @@ -80,7 +80,7 @@ console.log(indices); <code>idx > 0</code>时,才进入lastIndexOf由后往前移一位进行倒查找;如果<code>idx == 0</code>则直接设置<code>idx = -1</code>,循环<code>while (idx != -1)</code>就结束了。<br> </p> -<h2 id="Compatibility" name="Compatibility">兼容旧环境(Polyfill)</h2> +<h2 id="Compatibility">兼容旧环境(Polyfill)</h2> <p><code>lastIndexOf</code> 在 ECMA-262 标准第 5 版被添加。因此它在不兼容该标准的浏览器中可能不被支持。你可以把下面代码添加到脚本中来使那些没有实现该方法的实现环境支持该方法。该算法是被 ECMA-262 第 5 版指定的。假定 {{jsxref("Global_Objects/Object", "Object")}}、{{jsxref("Global_Objects/TypeError", "TypeError")}}、{{jsxref("Global_Objects/Number", "Number")}}、{{jsxref("Math.floor")}}、{{jsxref("Math.abs")}},以及 {{jsxref("Math.min")}} 拥有其初始值。</p> @@ -168,7 +168,7 @@ console.log(indices); <p>{{Compat("javascript.builtins.Array.lastIndexOf")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.indexOf()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html index de5862921d..dfab0b020f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/length/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/length <div>{{EmbedInteractiveExample("pages/js/array-length.html")}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>length</code> 属性的值是一个 0 到 2<sup>32</sup>-1 的整数。</p> @@ -76,9 +76,9 @@ function printEntries(arr) { <li><code>Enumerable</code> :如果设置为 <code>true</code> ,属性可以通过迭代器<a href="zh-CN/docs/Web/JavaScript/Reference/Statements/for">for</a>或<a href="/zh-CN/docs/Web/JavaScript/Reference/Statements/for...in">for...in</a>进行迭代。</li> </ul> -<h2 id="Examples" name="Examples">示例 </h2> +<h2 id="Examples">示例 </h2> -<h3 id="Example:_Iterating_over_an_array" name="Example:_Iterating_over_an_array">遍历数组</h3> +<h3 id="Example:_Iterating_over_an_array">遍历数组</h3> <p>下面的例子中,通过数组下标遍历数组元素,并把每个元素的值修改为原值的2倍。</p> @@ -89,7 +89,7 @@ for (var i = 0; i < length; i++) { } // 遍历后的结果 [2, 4, 6, 8, 10]</pre> -<h3 id="Example:_Shortening_an_array" name="Example:_Shortening_an_array">截断数组</h3> +<h3 id="Example:_Shortening_an_array">截断数组</h3> <p>下面的例子中,如果数组长度大于 3,则把该数组的长度截断为 3 。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html index 15e10d0329..dc8241fd26 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/map/index.html @@ -18,13 +18,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre><var>var new_array = arr</var>.map(function <var>callback(currentValue[, index[, array]]) { // Return element for new_array </var> <var>}</var>[, <var>thisArg</var>])</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>callback</code></dt> @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map <p>一个由原数组每个元素执行回调函数的结果组成的新数组。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>map</code> 方法会给原数组中的每个元素都按顺序调用一次 <code>callback</code> 函数。<code>callback</code> 每次执行后的返回值(包括 {{jsxref("undefined")}})组合起来形成一个新数组。 <code>callback</code> 函数只会在有值的索引上被调用;那些从来没被赋过值或者使用 <code>delete</code> 删除的索引则不会被调用。</p> @@ -62,9 +62,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map <p>根据规范中定义的算法,如果被map调用的数组是离散的,新数组将也是离散的保持相同的索引为空。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Mapping_an_array_of_numbers_to_an_array_of_square_roots" name="Example:_Mapping_an_array_of_numbers_to_an_array_of_square_roots">求数组中每个元素的平方根</h3> +<h3 id="Example_Mapping_an_array_of_numbers_to_an_array_of_square_roots">求数组中每个元素的平方根</h3> <p>下面的代码创建了一个新数组,值为原数组中对应数字的平方根。</p> @@ -94,7 +94,7 @@ var reformattedArray = kvArray.map(function(obj) { // {key: 3, value: 30}] </pre> -<h3 id="Example_Pluralizing_the_words_.28strings.29_in_an_array" name="Example:_Pluralizing_the_words_.28strings.29_in_an_array">使用一个包含一个参数的函数来mapping(构建)一个数字数组</h3> +<h3 id="Example_Pluralizing_the_words_.28strings.29_in_an_array">使用一个包含一个参数的函数来mapping(构建)一个数字数组</h3> <p>下面的代码表示了当函数需要一个参数时map的工作方式。当map循环遍历原始数组时,这个参数会自动被分配成数组中对应的每个元素。</p> @@ -106,7 +106,7 @@ var doubles = numbers.map(function(num) { // doubles数组的值为: [2, 8, 18] // numbers数组未被修改: [1, 4, 9]</pre> -<h3 id="Example_using_map_generically" name="Example:_using_map_generically">一般的<code>map</code> 方法</h3> +<h3 id="Example_using_map_generically">一般的<code>map</code> 方法</h3> <p>下面的例子演示如何在一个 {{jsxref("String")}} 上使用 map 方法获取字符串中每个字符所对应的 ASCII 码组成的数组:</p> @@ -334,7 +334,7 @@ if (!Array.prototype.map) { <p>{{Compat("javascript.builtins.Array.map")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.forEach()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/of/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/of/index.html index 9013ce9446..8c12486fe2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/of/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/of/index.html @@ -24,11 +24,11 @@ Array(7); // [ , , , , , , ] Array(1, 2, 3); // [1, 2, 3] </pre> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Array.of(<var>element0</var>[, <var>element1</var>[, ...[, <var>elementN</var>]]])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt>element<em>N</em></dt> @@ -50,7 +50,7 @@ Array.of(1, 2, 3); // [1, 2, 3] Array.of(undefined); // [undefined] </pre> -<h2 id="Compatibility" name="Compatibility">兼容旧环境</h2> +<h2 id="Compatibility">兼容旧环境</h2> <p>如果原生不支持的话,在其他代码之前执行以下代码会创建 <code>Array.of()</code> 。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/pop/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/pop/index.html index 3e6caa6795..9ee915c4f4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/pop/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/pop/index.html @@ -17,7 +17,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/pop -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>arr</em>.pop()</code></pre> @@ -25,7 +25,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/pop <p>从数组中删除的元素(当数组为空时返回{{jsxref("undefined")}})。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>pop</code> 方法从一个数组中删除并返回最后一个元素。</p> @@ -33,9 +33,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/pop <p>如果你在一个空数组上调用 pop(),它返回 {{jsxref("undefined")}}。</p> -<h2 id="Example" name="Example">示例</h2> +<h2 id="Example">示例</h2> -<h3 id="Example:_Removing_the_last_element_of_an_array" name="Example:_Removing_the_last_element_of_an_array">例子: 删除掉数组的最后一个元素</h3> +<h3 id="Example:_Removing_the_last_element_of_an_array">例子: 删除掉数组的最后一个元素</h3> <p>下面的代码首先创建了一个拥有四个元素的数组 myFish,然后删除掉它的最后一个元素。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/push/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/push/index.html index 032e985d22..fd1154f7c6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/push/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/push/index.html @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/push <p>当调用该方法时,新的 {{jsxref("Array.length", "length")}} 属性值将被返回。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>push方法将值追加到数组中。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/reverse/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/reverse/index.html index b408aa046f..2ec4feba05 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/reverse/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/reverse/index.html @@ -132,7 +132,7 @@ console.log(a); // {0: 3, 1: 2, 2: 1, length: 3}</code></pre> </div> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.join()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html index d62b834d40..74703cbe04 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/slice/index.html @@ -57,7 +57,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/slice <p>如果向两个数组任一中添加了新元素,则另一个不会受到影响。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="返回现有数组的一部分">返回现有数组的一部分</h3> @@ -108,7 +108,7 @@ The new color of my Honda is purple newCar[0].color = purple </pre> -<h2 id="Array-like" name="Array-like">类数组(Array-like)对象</h2> +<h2 id="Array-like">类数组(Array-like)对象</h2> <p><code>slice</code> 方法可以用来将一个类数组(Array-like)对象/集合转换成一个新数组。你只需将该方法绑定到这个对象上。 一个函数中的 {{jsxref("Functions/arguments", "arguments")}} 就是一个类数组对象的例子。</p> @@ -242,7 +242,7 @@ var list1 = list(1, 2, 3); // [1, 2, 3] <p>{{Compat("javascript.builtins.Array.slice")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.splice()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/some/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/some/index.html index 8c5aabec0f..a0f5695dfb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/some/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/some/index.html @@ -20,11 +20,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some <div>{{EmbedInteractiveExample("pages/js/array-some.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>arr</em>.some(<em>callback(element[, index[, array]])[, thisArg]</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>callback</code></dt> @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some <p>数组中有至少一个元素通过回调函数的测试就会返回<strong><code>true</code></strong>;所有元素都没有通过回调函数的测试返回值才会为false。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>some()</code> 为数组中的每一个元素执行一次 <code>callback</code> 函数,直到找到一个使得 callback 返回一个“真值”(即可转换为布尔值 true 的值)。如果找到了这样一个值,<code>some()</code> 将会立即返回 <code>true</code>。否则,<code>some()</code> 返回 <code>false</code>。<code>callback</code> 只会在那些”有值“的索引上被调用,不会在那些被删除或从来未被赋值的索引上调用。</p> @@ -58,9 +58,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some <p><code>some()</code> 遍历的元素的范围在第一次调用 <code>callback</code>. 前就已经确定了。在调用 <code>some()</code> 后被添加到数组中的值不会被 <code>callback</code> 访问到。如果数组中存在且还未被访问到的元素被 <code>callback</code> 改变了,则其传递给 <code>callback</code> 的值是 <code>some()</code> 访问到它那一刻的值。已经被删除的元素不会被访问到。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Testing_size_of_all_array_elements" name="Example:_Testing_size_of_all_array_elements">测试数组元素的值</h3> +<h3 id="Example_Testing_size_of_all_array_elements">测试数组元素的值</h3> <p>下面的例子检测在数组中是否有元素大于 10。</p> @@ -127,7 +127,7 @@ getBoolean(1); // true getBoolean('true'); // true </pre> -<h2 id="Compatibility" name="Compatibility">Polyfill</h2> +<h2 id="Compatibility">Polyfill</h2> <p>在第 5 版时,<code>some()</code> 被添加进 ECMA-262 标准;这样导致某些实现环境可能不支持它。你可以把下面的代码插入到脚本的开头来解决此问题,从而允许在那些没有原生支持它的实现环境中使用它。该算法是 ECMA-262 第 5 版中指定的算法,假定 <code>Object </code>和 <code>TypeError</code> 拥有他们的初始值,且 <code>fun.call</code> 等价于 <code>{{jsxref("Function.prototype.call")}}</code>。</p> @@ -196,7 +196,7 @@ if (!Array.prototype.some) { <p>{{Compat("javascript.builtins.Array.some")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.find()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/sort/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/sort/index.html index e4140bde3b..49a4339d87 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/sort/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/sort/index.html @@ -42,7 +42,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/sort <p>排序后的数组。请注意,数组已原地排序,并且不进行复制。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果没有指明 <code>compareFunction</code> ,那么元素会按照转换为的字符串的诸个字符的Unicode位点进行排序。例如 "Banana" 会被排列到 "cherry" 之前。当数字按由小到大排序时,9 出现在 80 之前,但因为(没有指明 <code>compareFunction</code>),比较的数字会先被转换为字符串,所以在Unicode顺序上 "80" 要比 "9" 要靠前。</p> @@ -129,9 +129,9 @@ items.sort(function(a, b) { return 0; });</pre> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Creating.2C_displaying.2C_and_sorting_an_array" name="Example:_Creating.2C_displaying.2C_and_sorting_an_array">创建、显示及排序数组</h3> +<h3 id="Example_Creating.2C_displaying.2C_and_sorting_an_array">创建、显示及排序数组</h3> <p>下述示例创建了四个数组,并展示原数组。之后对数组进行排序。对比了数字数组分别指定与不指定比较函数的结果。</p> @@ -179,7 +179,7 @@ Sorted without a compare function: 1,200,40,5,700,80,9 Sorted with compareNumbers: 1,5,9,40,80,200,700 </pre> -<h3 id="Example_Sorting_non-ASCII_characters" name="Example:_Sorting_non-ASCII_characters">对非 ASCII 字符排序</h3> +<h3 id="Example_Sorting_non-ASCII_characters">对非 ASCII 字符排序</h3> <p>当排序非 ASCII 字符的字符串(如包含类似 e, é, è, a, ä 等字符的字符串)。一些非英语语言的字符串需要使用 {{jsxref("String.localeCompare")}}。这个函数可以将函数排序到正确的顺序。</p> @@ -191,7 +191,7 @@ items.sort(function (a, b) { // items is ['adieu', 'café', 'cliché', 'communiqué', 'premier', 'réservé'] </pre> -<h3 id="Example_Sorting_maps" name="Example:_Sorting_maps">使用映射改善排序</h3> +<h3 id="Example_Sorting_maps">使用映射改善排序</h3> <p><code>compareFunction</code> 可能需要对元素做多次映射以实现排序,尤其当 <code>compareFunction</code> 较为复杂,且元素较多的时候,某些 <code>compareFunction</code> 可能会导致很高的负载。使用 map 辅助排序将会是一个好主意。基本思想是首先将数组中的每个元素比较的实际值取出来,排序后再将数组恢复。</p> @@ -253,7 +253,7 @@ var result = mapped.map(function(el){ ]; </pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -285,7 +285,7 @@ var result = mapped.map(function(el){ </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> <div> @@ -295,7 +295,7 @@ var result = mapped.map(function(el){ </div> </div> -<h2 id="See_also" name="See_also">参考</h2> +<h2 id="See_also">参考</h2> <ul> <li>{{jsxref("Array.prototype.reverse()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/tolocalestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/tolocalestring/index.html index 729e537627..b893cd7f87 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/tolocalestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/tolocalestring/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/toLocaleString <div>{{EmbedInteractiveExample("pages/js/array-tolocalestring.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>arr.toLocaleString([locales[,options]]);</code></pre> @@ -166,7 +166,7 @@ if (!Array.prototype.toLocaleString) { <p>{{Compat("javascript.builtins.Array.toLocaleString")}}</p> -<h2 id="See_also" name="See_also">参见</h2> +<h2 id="See_also">参见</h2> <ul> <li>{{jsxref("Array.prototype.toString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/tosource/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/tosource/index.html index 7ff8cff304..a5371b0a9f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/tosource/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/tosource/index.html @@ -5,25 +5,25 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/toSource --- <p>{{JSRef("Global_Objects", "Array")}}{{Non-standard_header}}</p> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p>返回一个字符串,代表该数组的源代码.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>array</em>.toSource()</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>在调试时,你可以使用<code>toSource方法</code>来查看一个数组的内容.</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Examining_the_source_code_of_an_array" name="Example:_Examining_the_source_code_of_an_array">例子: 查看数组的源码</h3> +<h3 id="Example:_Examining_the_source_code_of_an_array">例子: 查看数组的源码</h3> <pre class="brush:js">var alpha = new Array("a", "b", "c"); @@ -33,7 +33,7 @@ alpha.toSource(); //返回["a", "b", "c"]</pre> <p>{{Compat("javascript.builtins.Array.toSource")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Array/toString" title="JavaScript/Reference/Global_Objects/Array/toString">Array.toString</a></li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/tostring/index.html index 2378e078f8..3c41f1dbc4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/tostring/index.html @@ -13,12 +13,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/toString <div>{{EmbedInteractiveExample("pages/js/array-tostring.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="brush: js">arr.toString() </pre> -<h3 id="Parameters" name="Parameters">返回值</h3> +<h3 id="Parameters">返回值</h3> <p>一个表示指定的数组及其元素的字符串。</p> @@ -72,7 +72,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/toString <p>{{Compat("javascript.builtins.Array.toString")}}</p> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Array.prototype.join()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/unshift/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/unshift/index.html index b05c74e64f..e6e2a8b693 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/unshift/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/unshift/index.html @@ -17,12 +17,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/unshift <div>{{EmbedInteractiveExample("pages/js/array-unshift.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">arr.unshift(element1, ..., elementN) </pre> -<h3 id="Parameters" name="Parameters">参数列表</h3> +<h3 id="Parameters">参数列表</h3> <dl> <dt><code>elementN</code></dt> @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/unshift <dl> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>unshift</code> 方法会在调用它的类数组对象的开始位置插入给定的参数。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/boolean/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/boolean/tostring/index.html index e18ed5d604..847d1ace1d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/boolean/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/boolean/tostring/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Boolean/toString -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>bool</var>.toString()</pre> @@ -24,7 +24,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Boolean/toString <p>表示特定{{jsxref("Boolean")}}对象的字符串。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Boolean")}} 对象覆盖了 {{jsxref("Object")}} 对象的 <code>toString</code> 方法。并没有继承 {{jsxref("Object.prototype.toString()")}}。对于布尔对象,<code>toString</code> 方法返回该对象的字符串形式。</p> @@ -78,7 +78,7 @@ var myVar = flag.toString() <p>{{Compat("javascript.builtins.Boolean.toString")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.toString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/boolean/valueof/index.html b/files/zh-cn/web/javascript/reference/global_objects/boolean/valueof/index.html index 9f2cc2ee8d..62137bbdf6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/boolean/valueof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/boolean/valueof/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Boolean/valueOf -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>bool</var>.valueOf()</code></pre> @@ -24,15 +24,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Boolean/valueOf <p>给定{{jsxref("Boolean")}}对象的原始值</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Boolean")}}的 <code>valueOf</code> 方法返回一个{{jsxref("Boolean")}}对象或{{jsxref("Boolean")}}字面量的原始值作为布尔数据类型。</p> <p>该方法通常在 JavaScript 内部调用,而不是在代码中显式调用。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Using_valueOf" name="Example:_Using_valueOf">使用 <code>valueOf</code></h3> +<h3 id="Example:_Using_valueOf">使用 <code>valueOf</code></h3> <pre class="brush: js">x = new Boolean(); myVar = x.valueOf() // assigns false to myVar @@ -74,7 +74,7 @@ myVar = x.valueOf() // assigns false to myVar <p>{{Compat("javascript.builtins.Boolean.valueOf")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.valueOf()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html index 57f12998f6..7e7e429c3d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getdate/index.html @@ -11,21 +11,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDate -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox language-html">dateObj.getDate()</pre> -<h2 id="Parameters" name="Parameters">参数</h2> +<h2 id="Parameters">参数</h2> <p>无</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>getDate() </code>返回一个1 到 31的整数值。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getDate" name="Example:_Using_getDate">例子: 使用getDate()<code>方法</code></h3> +<h3 id="Example:_Using_getDate">例子: 使用getDate()<code>方法</code></h3> <p>下面第二条语句将值25赋给 day 变量,该值基于日期对象 <code>Xmax95</code>的值。</p> @@ -67,7 +67,7 @@ alert(day); // 25</pre> <p>{{Compat("javascript.builtins.Date.getDate")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCDate()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html index 584180a8fb..d9c68dacb4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getday/index.html @@ -11,18 +11,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDay -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox language-html"><em>dateObj</em>.getDay() </pre> -<h3 id="Description" name="Description">返回值</h3> +<h3 id="Description">返回值</h3> <p>根据本地时间,返回一个0到6之间的整数值,代表星期几: 0 代表星期日, 1 代表星期一,2 代表星期二, 依次类推。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example_Using_getDay" name="Example:_Using_getDay">使用<code>getDay()</code></h3> +<h3 id="Example_Using_getDay">使用<code>getDay()</code></h3> <p>下面第二条语句,基于{{jsxref("Date")}}对象 <code>Xmas95</code> 的值,把 1 赋值给 <code>weekday</code>。也就是说1995年12月25日是星期一。</p> @@ -77,7 +77,7 @@ console.log(new Intl.DateTimeFormat('de-DE', options).format(Xmas95)); <p>{{Compat("javascript.builtins.Date.getDay")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCDate()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getfullyear/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getfullyear/index.html index c29a10aa45..2791749e86 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getfullyear/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getfullyear/index.html @@ -19,12 +19,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getFullYear -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="brush: html">dateObj.getFullYear() </pre> -<h3 id="Description" name="Description">返回值</h3> +<h3 id="Description">返回值</h3> <p>根据当地时间,返回一个对应于给定日期的年份数字。</p> @@ -32,9 +32,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getFullYear <p><code>getFullYear()</code>返回的值是绝对数。 对于1000到9999之间的日期,<code>getFullYear()</code>返回一个四位数字,如1995。使用此函数确保在2000年后兼容。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getFullYear" name="Example:_Using_getFullYear">使用<code>getFullYear()</code></h3> +<h3 id="Example:_Using_getFullYear">使用<code>getFullYear()</code></h3> <p>下面的例子将当前年份的四位数值分配给变量<code>year</code>。</p> @@ -78,7 +78,7 @@ var year = today.getFullYear(); <p>{{Compat("javascript.builtins.Date.getFullYear")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCFullYear()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html index 62d35dd713..2046e96d75 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/gethours/index.html @@ -15,17 +15,17 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getHours <pre class="syntaxbox language-html"><var>dateObj</var>.getHours()</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h3 id="Description" name="Description">返回值</h3> +<h3 id="Description">返回值</h3> <p><code>getHours</code>返回一个0 到 23之间的整数值。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getHours" name="Example:_Using_getHours">例子:使用<code>getHours</code>方法</h3> +<h3 id="Example:_Using_getHours">例子:使用<code>getHours</code>方法</h3> <p>下面第二条语句,基于日期对象 <code>Xmas95 </code>的值,把 23 赋值给了变量 <code>hours。</code></p> @@ -65,7 +65,7 @@ alert(hours); // 23</pre> <p>{{Compat("javascript.builtins.Date.getHours")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCHours()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html index 2cbc0b9d30..231cf2d7f9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getmilliseconds/index.html @@ -11,21 +11,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox language-html"><var>dateObj</var>.getMilliseconds()</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h3 id="Description" name="Description">描述</h3> +<h3 id="Description">描述</h3> <p><code>getMilliseconds() </code>方法返回一个0 到 999的整数。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getMilliseconds" name="Example:_Using_getMilliseconds">例子:使用<code>getMilliseconds</code>方法</h3> +<h3 id="Example:_Using_getMilliseconds">例子:使用<code>getMilliseconds</code>方法</h3> <p>下例中,将当前时间的毫秒数赋值给变量 <code>ms</code>。</p> @@ -64,7 +64,7 @@ ms = Today.getMilliseconds();</pre> <p>{{Compat("javascript.builtins.Date.getMilliseconds")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCMilliseconds()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html index a27f4c265d..bd99ad3db0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getminutes/index.html @@ -9,21 +9,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMinutes <div>{{EmbedInteractiveExample("pages/js/date-getminutes.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox language-html">dateObj.getMinutes()</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h3 id="Description" name="Description">描述</h3> +<h3 id="Description">描述</h3> <p><code>getMinutes </code>返回一个0 到 59的整数值。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getMinutes" name="Example:_Using_getMinutes">例子:使用<code>getMinutes方法</code></h3> +<h3 id="Example:_Using_getMinutes">例子:使用<code>getMinutes方法</code></h3> <p>下例中,第二行语句运行过后,变量 <code>minutes </code>的值为15,也就是说 <code>Xmas95 </code>这个日期对象的值为某时15分某秒。</p> @@ -63,7 +63,7 @@ var minutes = Xmas95.getMinutes();</pre> <p>{{Compat("javascript.builtins.Date.getMinutes")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCMinutes()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getmonth/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getmonth/index.html index 63a953f263..ce008a4ba0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getmonth/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getmonth/index.html @@ -18,21 +18,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMonth -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox language-html">dateObj.getMonth()</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h3 id="Description" name="Description">返回值</h3> +<h3 id="Description">返回值</h3> <p><code>getMonth</code>返回一个0 到 11的整数值: 0 代表一月份,1 代表二月份, 2 代表三月份,依次类推。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getMonth" name="Example:_Using_getMonth">使用 <code>getMonth()</code></h3> +<h3 id="Example:_Using_getMonth">使用 <code>getMonth()</code></h3> <p>下面第二条语句,基于 {{jsxref("Date")}} 对象 Xmas95 的值,把11赋值给变量 <code>month。</code></p> @@ -79,7 +79,7 @@ console.log(month); // 11</pre> <p>{{Compat("javascript.builtins.Date.getMonth")}}</p> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCMonth()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html index 1cb80b2ea8..4543e5c2b2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getseconds/index.html @@ -11,21 +11,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getSeconds -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox language-html">dateObj.getSeconds()</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h3 id="Description" name="Description">描述</h3> +<h3 id="Description">描述</h3> <p>该方法返回一个 0 到 59 的整数值。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getSeconds" name="Example:_Using_getSeconds">例子: 使用<code>getSeconds方法</code></h3> +<h3 id="Example:_Using_getSeconds">例子: 使用<code>getSeconds方法</code></h3> <p>下面第二条语句,基于日期对象 <code>Xmas95</code> 的值,把 30 赋值给变量 <code>secs</code>。</p> @@ -67,7 +67,7 @@ var secs = Xmas95.getSeconds();</pre> <p>{{Compat("javascript.builtins.Date.getSeconds")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCSeconds()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/gettime/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/gettime/index.html index 8e8bb5bd41..d42eb7731c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/gettime/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/gettime/index.html @@ -18,19 +18,19 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getTime -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>dateObj.getTime() </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无。</p> -<h3 id="Description" name="Description">返回值</h3> +<h3 id="Description">返回值</h3> <p><code>getTime</code> 方法的返回值一个数值,表示从1970年1月1日0时0分0秒(UTC,即协调世界时)距离该日期对象所代表时间的毫秒数。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <h3 id="使用_getTime()_复制日期对象">使用 getTime() 复制日期对象</h3> @@ -86,7 +86,7 @@ console.log("Operation took " + (end.getTime() - start.getTime()) + " msec");</p <p>{{Compat("javascript.builtins.Date.getTime")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.setTime()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html index 90b7d1a962..7f2d81f94e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/gettimezoneoffset/index.html @@ -11,21 +11,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox language-html">dateObj.getTimezoneOffset()</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h3 id="Description" name="Description">返回值</h3> +<h3 id="Description">返回值</h3> <p>时区偏差(time-zone offset)表示协调世界时(UTC)与本地时区之间的差值,单位为分钟。需要注意的是如果本地时区后于协调世界时,则该差值为正值,如果先于协调世界时则为负值。例如你所在时区为 UTC+10(澳大利亚东部标准时间),将会返回 -600。对于同一个时区,夏令时(Daylight Saving Time)将会改变这个值。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example_Using_getTimezoneOffset" name="Example:_Using_getTimezoneOffset">例子: 使用<code>getTimezoneOffset方法</code></h3> +<h3 id="Example_Using_getTimezoneOffset">例子: 使用<code>getTimezoneOffset方法</code></h3> <pre class="brush:js">var x = new Date(); var currentTimeZoneOffsetInHours = x.getTimezoneOffset() / 60; diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getutcdate/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getutcdate/index.html index e5c6c73ef9..5f91b84e1a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getutcdate/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getutcdate/index.html @@ -9,21 +9,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getUTCDate <div>{{EmbedInteractiveExample("pages/js/date-getutcdate.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.getUTCDate()</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p><code>getUTCDate()</code> 返回一个 1 到 31 的整数值</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getUTCDate" name="Example:_Using_getUTCDate">例子: 使用 <code>getUTCDate()</code> 方法</h3> +<h3 id="Example:_Using_getUTCDate">例子: 使用 <code>getUTCDate()</code> 方法</h3> <p>下面的例子是把当前日期的天数部分赋值给变量 <code>day</code>.</p> @@ -64,7 +64,7 @@ var day = today.getUTCDate(); <p>{{Compat("javascript.builtins.Date.getUTCDate")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getDate()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getutcday/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getutcday/index.html index 97052ed86a..cdc417c67e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getutcday/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getutcday/index.html @@ -11,21 +11,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getUTCDay -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.getUTCDay()</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无。</p> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p><code>getUTCDay()</code> 方法返回一个对应一星期中第几天的整数:0 代表星期天,1 代表星期一,2 代表星期二,依次类推。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getUTCDay" name="Example:_Using_getUTCDay">例子: 使用 <code>getUTCDay()</code> 方法</h3> +<h3 id="Example:_Using_getUTCDay">例子: 使用 <code>getUTCDay()</code> 方法</h3> <p>下面的例子是把当前日期的星期部分赋值给变量 <code>weekday</code>。</p> @@ -66,7 +66,7 @@ var weekday = today.getUTCDay(); <p>{{Compat("javascript.builtins.Date.getUTCDay")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCDate()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getutcfullyear/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getutcfullyear/index.html index fcddc106e9..da28d32ca2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getutcfullyear/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getutcfullyear/index.html @@ -11,21 +11,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getUTCFullYear -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.getUTCFullYear()</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无。</p> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p><code>getUTCFullYear()</code> 返回一个绝对数值,符合 Year-2000 标准,例如 1995。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getUTCFullYear" name="Example:_Using_getUTCFullYear">例子: 使用 <code>getUTCFullYear()</code> 方法</h3> +<h3 id="Example:_Using_getUTCFullYear">例子: 使用 <code>getUTCFullYear()</code> 方法</h3> <p>下面的例子是把当前年份的四位数值复制给变量 <code>year</code>。</p> @@ -66,7 +66,7 @@ var year = today.getUTCFullYear(); <p>{{Compat("javascript.builtins.Date.getUTCFullYear")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getFullYear()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getutchours/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getutchours/index.html index 1ba8124b2e..15b62e78cf 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getutchours/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getutchours/index.html @@ -11,21 +11,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getUTCHours -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.getUTCHours()</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无。</p> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p><code>getUTCHours()</code> 返回一个 0 到 23 的整数。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getUTCHours" name="Example:_Using_getUTCHours">例子: 使用 <code>getUTCHours()</code> 方法</h3> +<h3 id="Example:_Using_getUTCHours">例子: 使用 <code>getUTCHours()</code> 方法</h3> <p>下例将当前时间的小时部分赋值给变量 <code>hours</code>。</p> @@ -66,7 +66,7 @@ var hours = today.getUTCHours(); <p>{{Compat("javascript.builtins.Date.getUTCHours")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getHours()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getutcmilliseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getutcmilliseconds/index.html index 11b4f14b24..a3d2f98568 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getutcmilliseconds/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getutcmilliseconds/index.html @@ -9,21 +9,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getUTCMilliseconds <div>{{EmbedInteractiveExample("pages/js/date-getutcmilliseconds.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.getUTCMilliseconds()</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无。</p> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p><code>getUTCMilliseconds()</code> 返回一个 0 到 999 的整数。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getUTCMilliseconds" name="Example:_Using_getUTCMilliseconds">例子: 使用 <code>getUTCMilliseconds()</code> 方法</h3> +<h3 id="Example:_Using_getUTCMilliseconds">例子: 使用 <code>getUTCMilliseconds()</code> 方法</h3> <p>下例将当前时间的毫秒部分赋值给变量 <code>milliseconds</code>。</p> @@ -64,7 +64,7 @@ var milliseconds = today.getUTCMilliseconds(); <p>{{Compat("javascript.builtins.Date.getUTCMilliseconds")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getMilliseconds()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getutcminutes/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getutcminutes/index.html index b1b7f85581..ea4408c4d3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getutcminutes/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getutcminutes/index.html @@ -9,21 +9,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getUTCMinutes <div>{{EmbedInteractiveExample("pages/js/date-getutcminutes.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.getUTCMinutes()</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无。</p> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p><code>getUTCMinutes()</code> 返回一个 0 到 59 的整数。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getUTCMinutes" name="Example:_Using_getUTCMinutes">例子: 使用 <code>getUTCMinutes()</code> 方法</h3> +<h3 id="Example:_Using_getUTCMinutes">例子: 使用 <code>getUTCMinutes()</code> 方法</h3> <p>下例将当前时间的分钟部分赋值给变量 <code>minutes</code>。</p> @@ -64,7 +64,7 @@ var minutes = today.getUTCMinutes(); <p>{{Compat("javascript.builtins.Date.getUTCMinutes")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getMinutes()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getutcmonth/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getutcmonth/index.html index 7b7147560d..6b2d4cd909 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getutcmonth/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getutcmonth/index.html @@ -11,21 +11,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getUTCMonth -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.getUTCMonth()</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无。</p> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p><code>getUTCMonth()</code> 返回一个 0 到 11 的整数,分别对应以下月份:0 代表一月,1 代表二月,2 代表三月,依次类推。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getUTCMonth" name="Example:_Using_getUTCMonth">例子: 使用 <code>getUTCMonth()</code> 方法</h3> +<h3 id="Example:_Using_getUTCMonth">例子: 使用 <code>getUTCMonth()</code> 方法</h3> <p>下例将当前时间的月份赋值给变量 <code>month</code>。</p> @@ -66,7 +66,7 @@ var month = today.getUTCMonth(); <p>{{Compat("javascript.builtins.Date.getUTCMonth")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getMonth()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getutcseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getutcseconds/index.html index 194de38a29..ef54de9e9c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getutcseconds/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getutcseconds/index.html @@ -9,21 +9,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getUTCSeconds <div>{{EmbedInteractiveExample("pages/js/date-getutcseconds.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.getUTCSeconds()</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无。</p> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p><code>getUTCSeconds()</code> 返回一个 0 到 59 的整数。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_getUTCSeconds" name="Example:_Using_getUTCSeconds">例子: 使用 <code>getUTCSeconds()</code> 方法</h3> +<h3 id="Example:_Using_getUTCSeconds">例子: 使用 <code>getUTCSeconds()</code> 方法</h3> <p>下例将当前时间的秒数部分赋值给变量 <code>seconds</code>。</p> @@ -64,7 +64,7 @@ var seconds = today.getUTCSeconds(); <p>{{Compat("javascript.builtins.Date.getUTCSeconds")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getSeconds()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/getyear/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/getyear/index.html index 1067341a6f..a35e5e4ac6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/getyear/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/getyear/index.html @@ -7,15 +7,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getYear <p>getYear() 方法返回指定的本地日期的年份。因为 <code>getYear</code> 不返回千禧年[full years] ("year 2000 problem"),所以这个方法不再被使用,现在替换为 {{jsxref("Date.getFullYear", "getFullYear")}} .</p> -<h2 id="Syntax" name="Syntax">Syntax</h2> +<h2 id="Syntax">Syntax</h2> <pre class="syntaxbox"><code>dateObj.getYear() </code></pre> -<h3 id="Parameters" name="Parameters">Parameters</h3> +<h3 id="Parameters">Parameters</h3> <p>None.</p> -<h3 id="Description" name="Description">Returns</h3> +<h3 id="Description">Returns</h3> <p>The <code>getYear</code> method returns the year minus 1900; thus:</p> @@ -27,9 +27,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getYear <p>To take into account years before and after 2000, you should use {{jsxref("Date.getFullYear", "getFullYear()")}} instead of <code>getYear</code> so that the year is specified in full.</p> -<h2 id="Backward_Compatibility" name="Backward_Compatibility">Backward Compatibility</h2> +<h2 id="Backward_Compatibility">Backward Compatibility</h2> -<h3 id="JavaScript_1.2_and_earlier" name="JavaScript_1.2_and_earlier">Behaviour in JavaScript 1.2 and earlier</h3> +<h3 id="JavaScript_1.2_and_earlier">Behaviour in JavaScript 1.2 and earlier</h3> <p>The <code>getYear</code> method returns either a 2-digit or 4-digit year:</p> @@ -38,9 +38,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getYear <li>For years less than 1900 or greater than 1999, the value returned by <code>getYear</code> is the four-digit year. For example, if the year is 1856, the value returned is 1856. If the year is 2026, the value returned is 2026.</li> </ul> -<h2 id="Examples" name="Examples">Examples</h2> +<h2 id="Examples">Examples</h2> -<h3 id="Example:_Years_between_1900_and_1999" name="Example:_Years_between_1900_and_1999">Example: Years between 1900 and 1999</h3> +<h3 id="Example:_Years_between_1900_and_1999">Example: Years between 1900 and 1999</h3> <p>The second statement assigns the value 95 to the variable <code>year</code>.</p> @@ -48,7 +48,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getYear var year = Xmas.getYear(); // returns 95 </pre> -<h3 id="Example:_Years_above_1999" name="Example:_Years_above_1999">Example: Years above 1999</h3> +<h3 id="Example:_Years_above_1999">Example: Years above 1999</h3> <p>The second statement assigns the value 100 to the variable <code>year</code>.</p> @@ -56,7 +56,7 @@ var year = Xmas.getYear(); // returns 95 var year = Xmas.getYear(); // returns 100 </pre> -<h3 id="Example:_Years_below_1900" name="Example:_Years_below_1900">Example: Years below 1900</h3> +<h3 id="Example:_Years_below_1900">Example: Years below 1900</h3> <p>The second statement assigns the value -100 to the variable <code>year</code>.</p> @@ -64,7 +64,7 @@ var year = Xmas.getYear(); // returns 100 var year = Xmas.getYear(); // returns -100 </pre> -<h3 id="Example:_Setting_and_getting_a_year_between_1900_and_1999" name="Example:_Setting_and_getting_a_year_between_1900_and_1999">Example: Setting and getting a year between 1900 and 1999</h3> +<h3 id="Example:_Setting_and_getting_a_year_between_1900_and_1999">Example: Setting and getting a year between 1900 and 1999</h3> <p>The second statement assigns the value 95 to the variable <code>year</code>, representing the year 1995.</p> @@ -103,7 +103,7 @@ var year = Xmas.getYear(); // returns 95 <p>{{Compat("javascript.builtins.Date.getYear")}}</p> -<h2 id="See_Also" name="See_Also">See also</h2> +<h2 id="See_Also">See also</h2> <ul> <li>{{jsxref("Date.prototype.getFullYear()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html index 5b0a6cf01d..eef2f86594 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html @@ -18,7 +18,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <p>显式调用:</p> @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse <pre class="syntaxbox"><code>new Date(<var>dateString</var>).getTime()</code> </pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>dateString</code></dt> @@ -42,7 +42,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse <dd>一个表示从1970-1-1 00:00:00 UTC到给定日期字符串所表示时间的毫秒数的数值。如果参数不能解析为一个有效的日期,则返回{{jsxref("NaN")}}。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>parse</code> 方法接受一个日期字符串(例如 "<code>Dec 25, 1995</code>"),并返回从1970-1-1 00:00:00 UTC到该日期字符串所表示日期的毫秒数。该方法在基于字符串值设置日期值时很有用,例如结合使用{{jsxref("Global_Objects/Date/setTime", "setTime()")}} 方法和 {{jsxref("Global_Objects/Date", "Date()")}} 构造函数。</p> @@ -60,7 +60,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse <p>由于 <code>parse()</code> 是 {{jsxref("Date")}} 的一个静态方法 , 所以应该使用 <code>Date.parse()</code> 来调用,而不是作为 {{jsxref("Date")}} 的实例方法。</p> -<h3 id="Differences in assumed time-zone" name="Differences in assumed time-zone">默认时区的区别</h3> +<h3 id="Differences in assumed time-zone">默认时区的区别</h3> <p>当输入为 "<code>March 7, 2014</code>" 时, <code>parse()</code> 将默认使用本地时区。但如果使用 ISO 格式如 <code>"2014-03-07"</code> ,则会被默认为 UTC (ES5 和 ECMAScript 2015) 时区。 因此除非系统本地时区为 UTC,由这些字符串解析出的 {{jsxref("Date")}} 对象可能会因为 ECMAScript 版本不同而代表不同的时间。这意味着两个看起来等效的字符串可能因为它们的格式不同而被转换成不同的值。</p> @@ -91,9 +91,9 @@ new Date('2014-25-23').toISOString(); Date.parse('foo-bar 2014'); // 返回: NaN</pre> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_parse" name="Example:_Using_parse">例子:使用 <code>Date.parse()</code></h3> +<h3 id="Example:_Using_parse">例子:使用 <code>Date.parse()</code></h3> <p>如果 <code>IPOdate</code> 是一个已经存在的 {{jsxref("Date")}} 对象,则可以把其设置为本地时间 1995年8月9日。如下:</p> @@ -169,11 +169,11 @@ Date.parse('foo-bar 2014'); <p>{{Compat("javascript.builtins.Date.parse")}}</p> -<h2 id="See_also" name="See_also">兼容性提示</h2> +<h2 id="See_also">兼容性提示</h2> <p>Firefox 49 {{geckoRelease(49)}} 修改了解析2位数年份的方式,从和 Internet Explorer 一致改为和 Google Chrome 浏览器一致。现在,2位数的年份小于等于 <code>50</code> 的将会被解析为21世纪的年份。比如, <code>04/16/17</code> ,在之前会被解析为 1917年4月16日,现在将被解析为 2017年4月16日。为了避免任何可能的同步问题或者有歧义的年份,推荐使用 ISO 8601 格式如 "2017-04-16" ({{bug(1265136)}})。</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.UTC()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setdate/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setdate/index.html index c2a3e5a5c5..9cbddc4177 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/setdate/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setdate/index.html @@ -11,18 +11,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setDate -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.setDate(<em>dayValue</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>dayValue</code></dt> <dd>一个整数,表示该月的第几天。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果 <code>dayValue</code> 超出了月份的合理范围,<code>setDate</code> 将会相应地更新 <code>Date</code> 对象。</p> @@ -30,9 +30,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setDate <p>如果dayValue被设置为负数,日期会设置为上个月最后一天往前数这个负数绝对值天数后的日期。-1会设置为上月最后一天的前一天(译者注:例如当前为4月,如果setDate(-2),则为3月29日)</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example_Using_setDate" name="Example:_Using_setDate">例子:使用<code>setDate</code>方法</h3> +<h3 id="Example_Using_setDate">例子:使用<code>setDate</code>方法</h3> <pre class="brush:js">var theBigDay = new Date(1962, 6, 7); // 1962-07-07 theBigDay.setDate(24); // 1962-07-24 @@ -69,7 +69,7 @@ theBigDay.setDate(32); // 1962-08-01</pre> <p>{{Compat("javascript.builtins.Date.setDate")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getDate()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html index e5693e9e07..5c85e43084 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setfullyear/index.html @@ -11,11 +11,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setFullYear -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox language-html">dateObj.setFullYear(yearValue[, monthValue[, dayValue]])</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>yearValue</code></dt> @@ -26,15 +26,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setFullYear <dd>一个1到31之间的整数值,表示月份中的第几天。如果你指定了 <code>dayValue</code> 参数,就必须同时指定 <code>monthValue</code>。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果没有指定 <code>monthValue</code> 和<code>dayValue</code> 参数,将会使用 <code>getMonth</code> 和<code>getDate</code> 方法的返回值。</p> <p>如果有一个参数超出了合理的范围,<code>setFullYear</code> 方法会更新其他参数值,日期对象的日期值也会被相应更新。 例如,为 <code>monthValue </code>指定 15, 则年份会加1,月份值会为3。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_setFullYear" name="Example:_Using_setFullYear">例子:使用<code>setFullYear</code>方法</h3> +<h3 id="Example:_Using_setFullYear">例子:使用<code>setFullYear</code>方法</h3> <pre class="brush:js language-js">var theBigDay = new Date(); theBigDay.setFullYear(1997);</pre> @@ -70,7 +70,7 @@ theBigDay.setFullYear(1997);</pre> <p>{{Compat("javascript.builtins.Date.setFullYear")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getUTCFullYear()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/sethours/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/sethours/index.html index 43786dadd9..a5708b4fd6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/sethours/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/sethours/index.html @@ -11,16 +11,16 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setHours -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">dateObj.setHours(<em>hoursValue</em>[, <em>minutesValue</em>[, <em>secondsValue</em>[, <em>msValue</em>]]]) </pre> -<h3 id="Versions_prior_to_JavaScript_1.3" name="Versions_prior_to_JavaScript_1.3">JavaScript 1.3版本之前</h3> +<h3 id="Versions_prior_to_JavaScript_1.3">JavaScript 1.3版本之前</h3> <pre class="syntaxbox"><code>dateObj.setHours(<em>hoursValue</em>) </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>hoursValue</code></dt> @@ -33,15 +33,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setHours <dd>一个 0 到 999 的数字,表示微秒数,如果指定了 <code>msValue</code> 参数,则必须同时指定 <code>minutesValue</code> 和 <code>secondsValue</code> 参数。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果不指定 <code>minutesValue</code>,<code>secondsValue</code> 和 <code>msValue</code> 参数,则会使用{{jsxref("Date.getMinutes", "getMinutes()")}},{{jsxref("Date.getSeconds", "getSeconds()")}} 和{{jsxref("Date.getMilliseconds", "getMilliseconds()")}} 方法的返回值。</p> <p>如果有一个参数超出了合理范围,<code>setHours</code> 会相应地更新日期对象中的日期信息。例如,如果为 <code>secondsValue</code> 指定了 100,则分钟会加 1,然后秒数使用 40。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_setHours" name="Example:_Using_setHours">例子:使用<code>setHours方法</code></h3> +<h3 id="Example:_Using_setHours">例子:使用<code>setHours方法</code></h3> <pre class="brush:js">var theBigDay = new Date(); theBigDay.setHours(7); @@ -78,7 +78,7 @@ theBigDay.setHours(7); <p>{{Compat("javascript.builtins.Date.setHours")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getHours()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setmilliseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setmilliseconds/index.html index f747c2696c..97a00241c7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/setmilliseconds/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setmilliseconds/index.html @@ -11,24 +11,24 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setMilliseconds -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.setMilliseconds(<em>millisecondsValue</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>millisecondsValue</code></dt> <dd>一个 0 到 999 的数字,表示豪秒数。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果指定的数字超出了合理范围,则日期对象的时间信息会被相应地更新。例如,如果指定了 1005,则秒数加 1,豪秒数为 5。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_setMilliseconds" name="Example:_Using_setMilliseconds">例子:使用<code>setMilliseconds</code></h3> +<h3 id="Example:_Using_setMilliseconds">例子:使用<code>setMilliseconds</code></h3> <pre class="brush:js">var theBigDay = new Date(); theBigDay.setMilliseconds(100); @@ -65,7 +65,7 @@ theBigDay.setMilliseconds(100); <p>{{Compat("javascript.builtins.Date.setMilliseconds")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getMilliseconds()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setminutes/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setminutes/index.html index fbc30b83fc..cb791e5a9c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/setminutes/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setminutes/index.html @@ -11,15 +11,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setMinutes -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.setMinutes(<em>minutesValue</em>[, <em>secondsValue</em>[, <em>msValue</em>]])</pre> -<h3 id="Versions_prior_to_JavaScript_1.3" name="Versions_prior_to_JavaScript_1.3"> JavaScript 1.3之前版本</h3> +<h3 id="Versions_prior_to_JavaScript_1.3"> JavaScript 1.3之前版本</h3> <pre class="syntaxbox"><var>dateObj</var>.setMinutes(<em>minutesValue</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>minutesValue</code></dt> @@ -36,15 +36,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setMinutes <dd>一个 0 到 999 的数字,表示微秒数,如果指定了 <code>msValue</code> 参数,则必须同时指定 <code>minutesValue</code> 和<code>secondsValue</code> 参数。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果没有指定 <code>secondsValue</code> 和 <code>msValue</code> 参数,就会使用 {{jsxref("Date.getSeconds", "getSeconds()")}} 和 {{jsxref("Date.getMilliseconds", "getmilliseconds()")}} 方法的返回值。</p> <p>如果有一个指定的参数超出了合理范围,<code>setMinutes</code> 会相应地更新日期对象中的时间信息。例如,为 <code>secondsValue</code> 指定 100,分钟数将会加 1,而秒数会为 40。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_setMinutes" name="Example:_Using_setMinutes">例子:使用<code>setMinutes方法</code></h3> +<h3 id="Example:_Using_setMinutes">例子:使用<code>setMinutes方法</code></h3> <pre class="brush: js">var theBigDay = new Date(); theBigDay.setMinutes(45); @@ -81,7 +81,7 @@ theBigDay.setMinutes(45); <p>{{Compat("javascript.builtins.Date.setMinutes")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getMinutes()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setmonth/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setmonth/index.html index fecc2f00a1..e7df1fc3d7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/setmonth/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setmonth/index.html @@ -9,15 +9,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setMonth <div>{{EmbedInteractiveExample("pages/js/date-setmonth.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.setMonth(<em>monthValue</em>[, <em>dayValue</em>])</pre> -<h3 id="Versions_prior_to_JavaScript_1.3" name="Versions_prior_to_JavaScript_1.3">JavaScript 1.3版本之前</h3> +<h3 id="Versions_prior_to_JavaScript_1.3">JavaScript 1.3版本之前</h3> <pre class="syntaxbox"><var>dateObj</var>.setMonth(<em>monthValue</em>)</pre> -<h3 id="Parameter" name="Parameter">参数</h3> +<h3 id="Parameter">参数</h3> <dl> <dt><code>monthValue</code></dt> @@ -31,15 +31,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setMonth <dd>基于 1 January 1970 00:00:00 UTC 开始计算的毫秒数</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果不指定 <code>dayValue</code> 参数,就会使用 {{jsxref("Date.getDate", "getDate")}} 方法的返回值。</p> <p>如果有一个指定的参数超出了合理范围,<code>setMonth</code> 会相应地更新日期对象中的日期信息。例如,为 <code>monthValue</code> 指定 15,则年份会加 1,月份将会使用 3。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example_Using_setMonth" name="Example:_Using_setMonth">例子:使用<code>setMonth方法</code></h3> +<h3 id="Example_Using_setMonth">例子:使用<code>setMonth方法</code></h3> <pre class="brush: js">var theBigDay = new Date(); theBigDay.setMonth(6); @@ -76,7 +76,7 @@ theBigDay.setMonth(6); <p>{{Compat("javascript.builtins.Date.setMonth")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getMonth()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setseconds/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setseconds/index.html index b22a9cfbf0..b61a894262 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/setseconds/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setseconds/index.html @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setSeconds -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.setSeconds(<em>secondsValue</em>[, <em>msValue</em>])</pre> @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setSeconds <pre class="syntaxbox"><var>dateObj</var>.setSeconds(<em>secondsValue</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>secondsValue</code></dt> @@ -28,15 +28,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setSeconds <dd>一个 0 到 999 的数字,表示微秒数。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果没有指定 <code>msValue</code> 参数,就会使用 {{jsxref("Date.getMilliseconds", "getMilliseconds()")}} 方法的返回值。</p> <p>如果一个参数超出了合理范围, <code>setSeconds</code> 方法会相应地更新日期对象的时间信息。例如,为 <code>secondsValue</code> 指定 100,则日期对象的分钟数会相应地加 1,秒数将会使用 40。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_setSeconds" name="Example:_Using_setSeconds">例子:使用<code>setSeconds方法</code></h3> +<h3 id="Example:_Using_setSeconds">例子:使用<code>setSeconds方法</code></h3> <pre class="brush:js">var theBigDay = new Date(); theBigDay.setSeconds(30) @@ -73,7 +73,7 @@ theBigDay.setSeconds(30) <p>{{Compat("javascript.builtins.Date.setSeconds")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getSeconds()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/settime/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/settime/index.html index d82c54d75d..ef3ce60645 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/settime/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/settime/index.html @@ -11,28 +11,28 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setTime -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.setTime(<em>timeValue</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>timeValue</code></dt> <dd>一个整数,表示从1970-1-1 00:00:00 UTC开始计时的毫秒数。</dd> <dt> - <h3 id="Parameters" name="Parameters">返回值</h3> + <h3 id="Parameters">返回值</h3> </dt> <dd>UTC 1970年1月1日00:00:00与更新日期之间的毫秒数(实际上是自变量的值)。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>使用 <code>setTime</code> 方法用来把一个日期时间赋值给另一个 <code>Date </code>对象。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example_Using_setTime" name="Example:_Using_setTime">例子:使用<code>setTime</code></h3> +<h3 id="Example_Using_setTime">例子:使用<code>setTime</code></h3> <pre>theBigDay = new Date("July 1, 1999"); sameAsBigDay = new Date(); @@ -70,7 +70,7 @@ sameAsBigDay.setTime(theBigDay.getTime()); <p>{{Compat("javascript.builtins.Date.setTime")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.getTime()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/setutcdate/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/setutcdate/index.html index d0f72b4a68..128188f71f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/setutcdate/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/setutcdate/index.html @@ -11,24 +11,24 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setUTCDate -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.setUTCDate(<var>dayValue</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>dayValue</code></dt> <dd>一个1-31的整形数字,用来指定日期。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果你指定的参数超出了范围,setUTCDate()会尝试更新对应的{{jsxref("Global_Objects/Date", "Date")}} 中的日期信息。例如,如果你使用了40来作为参数,但是{{jsxref("Global_Objects/Date", "Date")}} 中存储的月份为6月,那么日期将被改写为10且月份被增到7月。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Using_setUTCDate" name="Example:_Using_setUTCDate">使用Using <code>setUTCDate()</code></h3> +<h3 id="Example:_Using_setUTCDate">使用Using <code>setUTCDate()</code></h3> <pre class="brush: js">var theBigDay = new Date(); theBigDay.setUTCDate(20); @@ -67,7 +67,7 @@ theBigDay.setUTCDate(20); <p>{{Compat("javascript.builtins.Date.setUTCDate")}}</p> </div> -<h2 id="See_also" name="See_also">相关内容</h2> +<h2 id="See_also">相关内容</h2> <ul> <li>{{jsxref("Date.prototype.getUTCDate()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/todatestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/todatestring/index.html index 6162c68977..e82f87f07c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/todatestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/todatestring/index.html @@ -11,19 +11,19 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toDateString -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.toDateString()</code></pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Global_Objects/Date", "Date")}} 对象实例引用一个具体的时间点。调用 {{jsxref("Date.toString", "toString")}} 方法会以美式英语和人类易读的形式返回日期对象的格式化字符串。在 <a href="/en-US/docs/SpiderMonkey" title="SpiderMonkey">SpiderMonkey</a> 里,该字符串由日期部分(年月日)和其后的时间部分(时分秒及时区)组成。有时需要获取日期部分的字符串,这可以由 <code>toDateString</code> 方法完成。</p> <p>The <code>toDateString</code> method is especially useful because compliant engines implementing <a href="/en-US/docs/ECMAScript" title="ECMAScript">ECMA-262</a> may differ in the string obtained from <code>toString</code> for <code>Date</code> objects, as the format is implementation-dependent and simple string slicing approaches may not produce consistent results across multiple engines.</p> -<h2 id="Example" name="Example">例子</h2> +<h2 id="Example">例子</h2> -<h3 id="Example:_A_basic_usage_of_toDateString" name="Example:_A_basic_usage_of_toDateString">例子:<code>toDateString</code> 方法的简单使用</h3> +<h3 id="Example:_A_basic_usage_of_toDateString">例子:<code>toDateString</code> 方法的简单使用</h3> <pre class="brush:js">var d = new Date(1993, 6, 28, 14, 39, 7); @@ -61,7 +61,7 @@ println(d.toDateString()); // prints Wed Jul 28 1993</pre> <p>{{Compat("javascript.builtins.Date.toDateString")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.toLocaleDateString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/togmtstring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/togmtstring/index.html index 6891e3c04a..bacbfeb46a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/togmtstring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/togmtstring/index.html @@ -9,13 +9,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toGMTString <p><strong>Note</strong>: <code>toGMTString</code> is deprecated and should no longer be used, it's only there for backwards compatibility, use {{jsxref("Date.toUTCString", "toUTCString()")}} instead.</p> -<h2 id="Syntax" name="Syntax">Syntax</h2> +<h2 id="Syntax">Syntax</h2> <pre class="syntaxbox"><var>dateObj</var>.toGMTString()</pre> -<h2 id="Examples" name="Examples">Examples</h2> +<h2 id="Examples">Examples</h2> -<h3 id="Example:_Using_toGMTString" name="Example:_Using_toGMTString">Example: Using <code>toGMTString</code></h3> +<h3 id="Example:_Using_toGMTString">Example: Using <code>toGMTString</code></h3> <p>In this example, the <code>toGMTString</code> method converts the date to GMT (UTC) using the operating system's time-zone offset and returns a string value that is similar to the following form. The exact format depends on the platform.</p> @@ -56,7 +56,7 @@ console.log(str); // Mon, 18 Dec 1995 17:28:35 GMT <p>{{Compat("javascript.builtins.Date.toGMTString")}}</p> -<h2 id="See_Also" name="See_Also">See also</h2> +<h2 id="See_Also">See also</h2> <ul> <li>{{jsxref("Date.prototype.toLocaleDateString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/toisostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/toisostring/index.html index ee2f6a29bb..83dec2f8b1 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/toisostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/toisostring/index.html @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toISOString -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.toISOString()</pre> @@ -23,7 +23,7 @@ alert(today.toISOString()); // 返回2011-10-05T14:48:00.000Z <p>上例使用了非标准字符串的解析,该字符串在某些旧的浏览器(如IE)中可能无法被正确解析。</p> -<h2 id="Description" name="Description">Polyfill</h2> +<h2 id="Description">Polyfill</h2> <p>该方法在ECMA-262第5版中被标准化。对于那些不支持此方法的JS引擎可以通过加上下面的代码实现:</p> @@ -78,7 +78,7 @@ alert(today.toISOString()); // 返回2011-10-05T14:48:00.000Z <p>{{Compat("javascript.builtins.Date.toISOString")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.toLocaleDateString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/tojson/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/tojson/index.html index 91bc392260..917a1b4ffb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/tojson/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/tojson/index.html @@ -11,18 +11,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toJSON -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.toJSON()</code> </pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Date")}} 实例引用一个具体的时间点。 调用 <code>toJSON()</code> 返回一个 JSON 格式字符串(使用 {{jsxref("Date.prototype.toISOString()", "toISOString()")}}),表示该日期对象的值。默认情况下,这个方法常用于 {{Glossary("JSON")}}序列化{{jsxref("Date")}}对象。</p> -<h2 id="Example" name="Example">样例</h2> +<h2 id="Example">样例</h2> -<h3 id="Example:_Using_toJSON" name="Example:_Using_toJSON"><code>toJSON()</code> 样例</h3> +<h3 id="Example:_Using_toJSON"><code>toJSON()</code> 样例</h3> <pre class="brush:js">var date = new Date(); console.log(date); //Thu Nov 09 2017 18:54:04 GMT+0800 (中国标准时间) diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/tolocaledatestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/tolocaledatestring/index.html index 407050f518..080fdffba4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/tolocaledatestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/tolocaledatestring/index.html @@ -11,11 +11,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.toLocaleDateString([locales [, options]])</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p> 查看<a href="#Browser_Compatibility" title="#Browser_Compatibility">浏览器兼容性</a>小节,看下哪些浏览器支持 <code>locales</code> 和 <code>options</code> 参数,还可以参看<a href="#Example:_Checking_for_support_for_locales_and_options_arguments">例子: 检测 <code>locales</code> 和 <code>options</code> 参数支持情况</a>。</p> @@ -23,9 +23,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString <p>The default value for each date-time component property is <code>undefined</code>, but if the <code>weekday</code>, <code>year</code>, <code>month</code>, <code>day</code> properties are all <code>undefined</code>, then <code>year</code>, <code>month</code>, and <code>day</code> are assumed to be "numeric".</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_toLocaleDateString" name="Example:_Using_toLocaleDateString">例子:使用<code>toLocaleDateString</code></h3> +<h3 id="Example:_Using_toLocaleDateString">例子:使用<code>toLocaleDateString</code></h3> <p>没有指定语言环境(locale)时,返回一个使用默认语言环境和格式设置(options)的格式化字符串。</p> @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString date.toLocaleDateString(); // → "12/11/2012" if run in en-US locale with time zone America/Los_Angeles</pre> -<h3 id="Example:_Checking_for_support_for_locales_and_options_arguments" name="Example:_Checking_for_support_for_locales_and_options_arguments">例子:检测 <code>locales</code> 和 <code>options</code> 参数支持情况</h3> +<h3 id="Example:_Checking_for_support_for_locales_and_options_arguments">例子:检测 <code>locales</code> 和 <code>options</code> 参数支持情况</h3> <p><code>locales</code> 和 <code>options</code> 参数不是所有的浏览器都支持。为了检测一种实现环境(implementation)是否支持它们,可以使用不合法的语言标签,如果实现环境支持该参数,则会抛出一个 <code>RangeError</code> 异常,反之会忽略参数。</p> @@ -50,7 +50,7 @@ date.toLocaleDateString(); } </pre> -<h3 id="Example:_Using_locales" name="Example:_Using_locales">例子:使用<code>locales</code></h3> +<h3 id="Example:_Using_locales">例子:使用<code>locales</code></h3> <p>下例展示了本地化日期格式的一些变化。为了在应用的用户界面得到某种语言的日期格式,必须确保使用 <code>locales</code> 参数指定了该语言(可能还需要设置某些回退语言)。</p> @@ -86,7 +86,7 @@ alert(date.toLocaleDateString(["ban", "id"])); // → "20/12/2012" </pre> -<h3 id="Example:_Using_options" name="Example:_Using_options">例子:使用<code>options</code></h3> +<h3 id="Example:_Using_options">例子:使用<code>options</code></h3> <p>可以使用 <code>options </code>参数来自定义 <code>toLocaleDateString</code> 方法返回的字符串。</p> @@ -104,7 +104,7 @@ alert(date.toLocaleDateString("en-US", options)); // → "Thursday, December 20, 2012, GMT" </pre> -<h2 id="Performance" name="Performance">性能</h2> +<h2 id="Performance">性能</h2> <p>当格式化大量日期时,最好创建一个 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat" title="/en-US/docs/JavaScript/Reference/Global_Objects/DateTimeFormat"><code>Intl.DateTimeFormat</code></a> 对象,然后使用该对象 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format" title="/en-US/docs/JavaScript/Reference/Global_Objects/DateTimeFormat/format"><code>format</code></a> 属性提供的方法。</p> @@ -144,7 +144,7 @@ alert(date.toLocaleDateString("en-US", options)); <p>{{Compat("javascript.builtins.Date.toLocaleDateString")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/DateTimeFormat", "DateTimeFormat")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/tolocalestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/tolocalestring/index.html index a5b2885180..944af31c7e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/tolocalestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/tolocalestring/index.html @@ -11,11 +11,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleString -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj.toLocaleString([locales [, options]])</var></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>查看<a href="#Browser_Compatibility" title="#Browser_Compatibility">浏览器兼容性</a>小节,看下哪些浏览器支持 <code>locales</code> 和 <code>options</code> 参数,还可以参看<a href="#Example:_Checking_for_support_for_locales_and_options_arguments">例子:检测 <code>locales</code> 和 <code>options</code> 参数支持情况</a>。</p> @@ -27,9 +27,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleString <p>根据当地语言规定返回代表着时间的字符串。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_toLocaleString" name="Example:_Using_toLocaleString">例子:使用 <code>toLocaleString</code></h3> +<h3 id="Example:_Using_toLocaleString">例子:使用 <code>toLocaleString</code></h3> <p>没有指定语言环境(locale)时,返回一个使用默认语言环境和格式设置(options)的格式化字符串。</p> @@ -40,7 +40,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleString date.toLocaleString(); // → 如果是在en-US区域和America/Los_Angeles时区运行返回值为"12/11/2012, 7:00:00 PM"</pre> -<h3 id="Example:_Checking_for_support_for_locales_and_options_arguments" name="Example:_Checking_for_support_for_locales_and_options_arguments">例子:检测 <code>locales</code> 和 <code>options</code> 参数支持情况</h3> +<h3 id="Example:_Checking_for_support_for_locales_and_options_arguments">例子:检测 <code>locales</code> 和 <code>options</code> 参数支持情况</h3> <p><code>locales</code> 和 <code>options</code> 参数不是所有的浏览器都支持。为了检测一种实现环境(implementation)是否支持它们,可以使用不合法的语言标签,如果实现环境支持该参数,则会抛出一个 <code>RangeError</code> 异常,反之会忽略参数。</p> @@ -54,7 +54,7 @@ date.toLocaleString(); } </pre> -<h3 id="Example:_Using_locales" name="Example:_Using_locales">例子:使用 <code>locales</code> 参数</h3> +<h3 id="Example:_Using_locales">例子:使用 <code>locales</code> 参数</h3> <p>下例展示了本地化日期格式的一些变化。为了在应用的用户界面得到某种语言的日期和时间格式,必须确保使用 <code>locales</code> 参数指定了该语言(可能还需要设置某些回退语言)。</p> @@ -88,7 +88,7 @@ alert(date.toLocaleString(["ban", "id"])); // → "20/12/2012 11.00.00" </pre> -<h3 id="Example:_Using_options" name="Example:_Using_options">例子:使用 <code>options</code> 参数</h3> +<h3 id="Example:_Using_options">例子:使用 <code>options</code> 参数</h3> <p>可以使用 <code>options </code>参数来自定义 <code>toLocaleString</code> 方法返回的字符串。</p> @@ -110,7 +110,7 @@ alert(date.toLocaleString("en-US", {hour12: false})); // → "12/19/2012, 19:00:00" </pre> -<h2 id="Performance" name="Performance">性能</h2> +<h2 id="Performance">性能</h2> <p>当格式化大量日期时,最好创建一个 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat" title="/en-US/docs/JavaScript/Reference/Global_Objects/DateTimeFormat"><code>Intl.DateTimeFormat</code></a> 对象,然后使用该对象 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format" title="/en-US/docs/JavaScript/Reference/Global_Objects/DateTimeFormat/format"><code>format</code></a> 属性提供的方法。</p> @@ -150,7 +150,7 @@ alert(date.toLocaleString("en-US", {hour12: false})); <p>{{Compat("javascript.builtins.Date.toLocaleString")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/DateTimeFormat", "DateTimeFormat")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/tolocaletimestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/tolocaletimestring/index.html index cf32bed733..f28a479d75 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/tolocaletimestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/tolocaletimestring/index.html @@ -11,11 +11,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.toLocaleTimeString([locales [, options]])</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>查看<a href="#Browser_Compatibility" title="#Browser_Compatibility">浏览器兼容性</a>小节,看下哪些浏览器支持 <code>locales</code> 和 <code>options</code> 参数,还可以参看<a href="#Example:_Checking_for_support_for_locales_and_options_arguments">例子:检测 <code>locales</code> 和 <code>options</code> 参数支持情况</a>。</p> @@ -23,9 +23,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString <p>The default value for each date-time component property is <code>undefined</code>, but if the <code>hour</code>, <code>minute</code>, <code>second</code> properties are all <code>undefined</code>, then <code>hour</code>, <code>minute</code>, and <code>second</code> are assumed to be "numeric".</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_toLocaleTimeString" name="Example:_Using_toLocaleTimeString">例子:使用 <code>toLocaleTimeString</code></h3> +<h3 id="Example:_Using_toLocaleTimeString">例子:使用 <code>toLocaleTimeString</code></h3> <p>没有指定语言环境(locale)时,返回一个使用默认语言环境和格式设置(options)的格式化字符串。</p> @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString alert(date.toLocaleTimeString()); // → "7:00:00 PM" if run in en-US locale with time zone America/Los_Angeles</pre> -<h3 id="Example:_Checking_for_support_for_locales_and_options_arguments" name="Example:_Checking_for_support_for_locales_and_options_arguments">例子:检测 <code>locales</code> 和 <code>options</code> 支持情况</h3> +<h3 id="Example:_Checking_for_support_for_locales_and_options_arguments">例子:检测 <code>locales</code> 和 <code>options</code> 支持情况</h3> <p><code>locales</code> 和 <code>options</code> 参数不是所有的浏览器都支持。为了检测一种实现环境(implementation)是否支持它们,可以使用不合法的语言标签,如果实现环境支持该参数,则会抛出一个 <code>RangeError</code> 异常,反之会忽略参数。</p> @@ -50,7 +50,7 @@ alert(date.toLocaleTimeString()); } </pre> -<h3 id="Example:_Using_locales" name="Example:_Using_locales">例子:使用 <code>locales</code> 参数</h3> +<h3 id="Example:_Using_locales">例子:使用 <code>locales</code> 参数</h3> <p>下例展示了本地化时间格式的一些变化。为了在应用的用户界面得到某种语言的时间格式,必须确保使用 <code>locales</code> 参数指定了该语言(可能还需要设置某些回退语言)。</p> @@ -81,7 +81,7 @@ alert(date.toLocaleTimeString(["ban", "id"])); // → "11.00.00" </pre> -<h3 id="Example:_Using_options" name="Example:_Using_options">例子:使用 <code>options</code> 参数</h3> +<h3 id="Example:_Using_options">例子:使用 <code>options</code> 参数</h3> <p>可以使用 <code>options </code>参数来自定义 <code>toLocaleTimeString</code> 方法返回的字符串。</p> @@ -97,7 +97,7 @@ alert(date.toLocaleTimeString("en-US", {hour12: false})); // → "19:00:00" </pre> -<h2 id="Performance" name="Performance">性能</h2> +<h2 id="Performance">性能</h2> <p>当格式化大量日期时,最好创建一个 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat" title="/en-US/docs/JavaScript/Reference/Global_Objects/DateTimeFormat"><code>Intl.DateTimeFormat</code></a> 对象,然后使用该对象 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format" title="/en-US/docs/JavaScript/Reference/Global_Objects/DateTimeFormat/format"><code>format</code></a> 属性提供的方法。</p> @@ -139,7 +139,7 @@ alert(date.toLocaleTimeString("en-US", {hour12: false})); <p>{{Compat("javascript.builtins.Date.toLocaleTimeString")}}</p> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/DateTimeFormat", "DateTimeFormat")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/tostring/index.html index 274418bf39..80663da2f0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/tostring/index.html @@ -11,15 +11,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toString -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.toString()</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Date")}}对象覆盖了 {{jsxref("Object")}} 对象的 <code>toString() </code>方法;它不是继承自 {{jsxref("Object.prototype.toString()")}}。对于 {{jsxref("Date")}} 对象,<code>toString()</code> 方法返回一个表示该对象的字符串。</p> @@ -29,9 +29,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toString <p><code>toString() </code>是通用函数。如果不是{{jsxref("Date")}}实例,则 返回"Invalid Date"。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_toString" name="Example:_Using_toString">例子: 使用 <code>toString</code> 方法</h3> +<h3 id="Example:_Using_toString">例子: 使用 <code>toString</code> 方法</h3> <p>下例把一个{{jsxref("Date")}}对象的 <code>toString</code> 返回值赋给 <code>myVar:</code></p> @@ -78,7 +78,7 @@ myVar = x.toString(); // 把类似于下面格式的值赋给 myVar, <p>{{Compat("javascript.builtins.Date.toString")}}</p> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.toString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/totimestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/totimestring/index.html index faa183e9cf..53cdaee185 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/totimestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/totimestring/index.html @@ -11,19 +11,19 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toTimeString -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.toTimeString()</pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Global_Objects/Date", "Date")}} 对象的实例引用一个具体的时间点。 调用 {{jsxref("Date.toString", "toString")}} 方法以美式英语和人类易读的形式,返回日期对象的格式化字符串。在 <a href="/en-US/docs/SpiderMonkey" title="SpiderMonkey">SpiderMonkey</a> 里,该字符串由日期部分(年月日)和其后的时间部分(时分秒和时区)组成。有时会需要获取时间部分的字符串,这可以由 <code>toTimeString</code> 方法完成。</p> <p>The <code>toTimeString</code> method is especially useful because compliant engines implementing <a href="https://developer.mozilla.org/en-US/docs/ECMAScript" title="ECMAScript">ECMA-262</a> may differ in the string obtained from <code>toString</code> for <code>Date</code> objects, as the format is implementation-dependent; simple string slicing approaches may not produce consistent results across multiple engines.</p> -<h2 id="Example" name="Example">例子</h2> +<h2 id="Example">例子</h2> -<h3 id="Example:_A_basic_usage_of_toTimeString" name="Example:_A_basic_usage_of_toTimeString">例子:<code>toTimeString</code> 方法的简单使用</h3> +<h3 id="Example:_A_basic_usage_of_toTimeString">例子:<code>toTimeString</code> 方法的简单使用</h3> <pre class="brush:js">var d = new Date(1993, 6, 28, 14, 39, 7); @@ -62,7 +62,7 @@ println(d.toTimeString()); // prints 14:39:07 GMT-0600 (PDT) <p>{{Compat("javascript.builtins.Date.toTimeString")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.toLocaleTimeString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/toutcstring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/toutcstring/index.html index 94caba73dd..4ec941d0db 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/toutcstring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/toutcstring/index.html @@ -11,23 +11,23 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toUTCString -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>dateObj</var>.toUTCString()</pre> -<h3 id="Parameters" name="Parameters">返回值</h3> +<h3 id="Parameters">返回值</h3> <p>返回使用UTC时区表示给定日期的字符串</p> <p> </p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>toUTCString</code> 的返回值是一个使用UTC时区的易读格式字符串。返回值的格式可能随平台而变化。通常返回值是一个 RFC-1123 格式的时间戳,这是一个 RFC-822 时间戳的小幅更新版。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_toUTCString" name="Example:_Using_toUTCString">例子:使用<code>toUTCString</code></h3> +<h3 id="Example:_Using_toUTCString">例子:使用<code>toUTCString</code></h3> <pre>var today = new Date(); var UTCstring = today.toUTCString(); @@ -65,7 +65,7 @@ var UTCstring = today.toUTCString(); <p>{{Compat("javascript.builtins.Date.toUTCString")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.toLocaleString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/utc/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/utc/index.html index 2ea01679de..ba2fdc8a6b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/utc/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/utc/index.html @@ -15,11 +15,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/UTC -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Date.UTC(<em>year</em>,<em>month</em>[,<em>date</em>[,<em>hrs</em>[,<em>min</em>[,<em>sec</em>{{mediawiki.external(',<em>ms</em>')}}]]]]) </code></pre> -<h2 id="Parameters" name="Parameters">参数</h2> +<h2 id="Parameters">参数</h2> <dl> <dt><code>year</code></dt> @@ -38,7 +38,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/UTC <dd>0 到 999 之间的一个整数,表示毫秒。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>UTC</code> 方法接受以逗号隔开的日期参数,返回1970-1-1 00:00:00 UTC到指定的日期之间的毫秒数。</p> @@ -55,9 +55,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/UTC <p>由于 <code>UTC</code> 是 <code>Date</code>(日期对象)的一个静态方法,所以应该在 <code>Date </code>上直接调用,就像 <code>Date.UTC()</code>,而不要把它作为创建的日期对象的方法。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_Date.UTC" name="Example:_Using_Date.UTC">例子:使用 <code>Date.UTC</code></h3> +<h3 id="Example:_Using_Date.UTC">例子:使用 <code>Date.UTC</code></h3> <p>下面的语句使用 UTC 时间代替本地时间创建了一个日期对象。</p> @@ -95,7 +95,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/UTC <p>{{Compat("javascript.builtins.Date.UTC")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.parse()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html index 2a441189e5..2b61fccc35 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/valueof/index.html @@ -16,15 +16,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/valueOf <div>{{EmbedInteractiveExample("pages/js/date-valueof.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>dateObj</var>.valueOf()</code></pre> -<h3 id="Parameters" name="Parameters">返回值</h3> +<h3 id="Parameters">返回值</h3> <p>从1970年1月1日0时0分0秒(UTC,即协调世界时)到该日期的毫秒数。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>valueOf</code> 方法返回以数值格式表示的一个 <code>Date</code> 对象的原始值,从1970年1月1日0时0分0秒(UTC,即协调世界时)到该日期对象所代表时间的毫秒数。</p> @@ -32,9 +32,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/valueOf <p>该方法通常在 JavaScript 内部被调用,而不是在代码中显式调用。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Using_valueOf" name="Example:_Using_valueOf">使用 <code>valueOf()</code></h3> +<h3 id="Example:_Using_valueOf">使用 <code>valueOf()</code></h3> <pre class="brush:js">var x = new Date(56, 6, 17); var myVar = x.valueOf(); // assigns -424713600000 to myVar @@ -76,7 +76,7 @@ var myVar = x.valueOf(); // assigns -424713600000 to myVar <p>{{Compat("javascript.builtins.Date.valueOf")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.valueOf()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/index.html index fe9ad2deed..82acc4e18f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/index.html @@ -11,11 +11,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error <p>通过<strong>Error</strong>的构造器可以创建一个错误对象。当运行时错误产生时,Error的实例对象会被抛出。Error对象也可用于用户自定义的异常的基础对象。下面列出了各种内建的标准错误类型。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="brush: js">new Error([<em>message</em>[, <em>fileName</em>[,<em>lineNumber</em>]]])</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>message</code></dt> @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error <dd>可选。被创建的Error对象的lineNumber属性值。默认是调用Error构造器代码所在的文件的行号。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>当代码运行时的发生错误,会创建新的<code>Error</code> 对象,并将其抛出。</p> @@ -47,7 +47,7 @@ const x = Error('I was created using a function call!'); // has the same functionality as this: const y = new Error('I was constructed via the "new" keyword!');</code></pre> -<h3 id="Error_types" name="Error_types">Error 类型</h3> +<h3 id="Error_types">Error 类型</h3> <p>除了通用的Error构造函数外,JavaScript还有6个其他类型的错误构造函数。更多客户端异常,详见 <a href="/en/JavaScript/Guide/Statements#Exception_Handling_Statements" title="en/JavaScript/Guide/Statements#Exception Handling Statements">Exception Handling Statements</a>。</p> @@ -83,18 +83,18 @@ const y = new Error('I was constructed via the "new" keyword!');</code></pre> <dd>创建一个error实例,表示错误的原因:给 {{jsxref("Global_Objects/encodeURI", "encodeURI()")}}或 {{jsxref("Global_Objects/decodeURI", "decodeURI()")}}传递的参数无效。</dd> </dl> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt>{{jsxref("Error.prototype")}}</dt> <dd>允许添加属性到<code>Error</code>实例。</dd> </dl> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <p>全局<code>Error</code>对象自身不包含任何方法,但从原型链中继承了一些方法.</p> -<h2 id="Error_instances" name="Error_instances"><code>Error</code> 实例</h2> +<h2 id="Error_instances"><code>Error</code> 实例</h2> <div> <p>{{page('en-US/docs/JavaScript/Reference/Global_Objects/Error/prototype', 'Description')}}</p> @@ -108,9 +108,9 @@ const y = new Error('I was constructed via the "new" keyword!');</code></pre> <p>{{page('en-US/docs/JavaScript/Reference/Global_Objects/Error/prototype', 'Methods')}}</p> </div> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example_Throwing_a_generic_error" name="Example:_Throwing_a_generic_error">抛出一个基本错误</h3> +<h3 id="Example_Throwing_a_generic_error">抛出一个基本错误</h3> <p>通常你会使用{{jsxref("Statements/throw", "throw")}}关键字来抛出你创建的Error对象。可以使用 {{jsxref("Statements/try...catch", "try...catch")}} 结构来处理异常:</p> @@ -121,7 +121,7 @@ const y = new Error('I was constructed via the "new" keyword!');</code></pre> } </pre> -<h3 id="Example_Handling_a_specific_error" name="Example:_Handling_a_specific_error">处理一个特定错误</h3> +<h3 id="Example_Handling_a_specific_error">处理一个特定错误</h3> <p>你可以通过判断异常的类型来特定处理某一类的异常,即判断 {{jsxref("Object.prototype.constructor", "constructor")}} 属性,当使用现代Javascript引擎时,可使用{{jsxref("Operators/instanceof", "instanceof")}} 关键字:</p> @@ -248,7 +248,7 @@ try { <div>{{Compat("javascript.builtins.Error")}}</div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Error.prototype")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/message/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/message/index.html index e846ff838c..ff4dce9d23 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/message/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/message/index.html @@ -5,19 +5,19 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/message --- <div>{{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>message</strong></code> 属性是有关错误信息,人类易读的(human-readable)描述。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果该属性已经被设置,则该属性包含了错误的一个简短描述。<a href="/en-US/docs/Mozilla/Projects/SpiderMonkey">SpiderMonkey</a> 大量应用 <code>message</code> 属性在异常方面。 <code>message</code> 属性结合 {{jsxref("Error.prototype.name", "name")}} 属性一起被 {{jsxref("Error.prototype.toString()")}} 方法用来创建错误的字符串形式。</p> <p>默认情况下,<code>message</code> 属性是一个空字符串,但是可以通过指定一段信息作为 {{jsxref("Error", "Error constructor")}} 的第一个参数创建一个实例来改变该属性值。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Throwing_a_custom_error" name="Example:_Throwing_a_custom_error">例子:抛出一个自定义错误</h3> +<h3 id="Example:_Throwing_a_custom_error">例子:抛出一个自定义错误</h3> <pre class="brush: js">var e = new Error("Could not parse input"); // e.message is "Could not parse input" throw e; @@ -102,7 +102,7 @@ throw e; </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Error.prototype.name")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/name/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/name/index.html index 0903c6e059..80848f54dc 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/name/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/name/index.html @@ -5,17 +5,17 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/name --- <p>{{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}</p> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>name</strong></code> 属性表示error类型的名称.初始值为"Error".</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>默认情况下,{{jsxref("Error")}}对象的<code>name</code>属性值为"Error".<code>name属性和</code>{{jsxref("Error.prototype.message", "message")}}属性一起,通过调用{{jsxref("Error.prototype.toString()")}}方法,会作为最后异常信息的字符串表示.</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Throwing_a_custom_error" name="Example:_Throwing_a_custom_error">例子: 抛出一个自定义错误</h3> +<h3 id="Example:_Throwing_a_custom_error">例子: 抛出一个自定义错误</h3> <pre class="brush:js">var e = new Error("Malformed input"); // e.name默认是"Error" @@ -102,7 +102,7 @@ throw e; // "ParseError: Malformed input" </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Error.prototype.message")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/tostring/index.html index a7e6a10ace..395d61aee2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/tostring/index.html @@ -5,11 +5,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/toString --- <div> {{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>toString()</strong></code> 方法返回一个指定的错误对象(Error object)的字符串表示。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>e</em>.toString();</code></pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Error")}} 对象覆盖了 {{jsxref("Object.prototype.toString()")}} 方法。该方法实现如下:(假定 <code>Object</code> 和 <code>String</code> 没有被更改):</p> <pre class="brush:js">Error.prototype.toString = function() { @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/toString return name + ": " + msg; }; </pre> -<h2 id="Example" name="Example">示例</h2> +<h2 id="Example">示例</h2> <pre class="brush:js">var e = new Error("fatal error"); print(e.toString()); // "Error: fatal error" @@ -123,7 +123,7 @@ print(e.toString()); // "hello" </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Error.prototype.toSource()")}}</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/escape/index.html b/files/zh-cn/web/javascript/reference/global_objects/escape/index.html index 72fd5e66e2..dc558d27bd 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/escape/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/escape/index.html @@ -9,22 +9,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/escape </div> </div> -<h2 id="Summary" name="Summary">概览</h2> +<h2 id="Summary">概览</h2> <p>废弃的 <code><strong>escape()</strong></code> 方法生成新的由十六进制转义序列替换的字符串. 使用 {{jsxref("Global_Objects/encodeURI", "encodeURI")}} 或 {{jsxref("Global_Objects/encodeURIComponent", "encodeURIComponent")}} 代替.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>escape(str)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>str</code></dt> <dd>待编码的字符串.</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>escape</code> 函数是全局对象的属性. 特色字符如: @*_+-./ 被排除在外.</p> @@ -118,7 +118,7 @@ escape("@*_+-./"); // "@*_+-./"</pre> </table> </div> -<h2 id="See_Also" name="See_Also">其他链接</h2> +<h2 id="See_Also">其他链接</h2> <ul> <li>{{jsxref("Global_Objects/encodeURI", "encodeURI")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/eval/index.html b/files/zh-cn/web/javascript/reference/global_objects/eval/index.html index 9e2ecdfcef..44639c6de0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/eval/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/eval/index.html @@ -58,7 +58,7 @@ eval(expression.toString()); <code> (0, eval)('x + y'); // 另一个间接调用的例子 </code>}</pre> -<h2 id="Don.27t_use_eval.21" name="Don.27t_use_eval.21">永远不要使用 <code>eval</code>!</h2> +<h2 id="Don.27t_use_eval.21">永远不要使用 <code>eval</code>!</h2> <p><code>eval()</code> 是一个危险的函数, 它使用与调用者相同的权限执行代码。如果你用 <code>eval()</code> 运行的字符串代码被恶意方(不怀好意的人)修改,您最终可能会在您的网页/扩展程序的权限下,在用户计算机上运行恶意代码。更重要的是,第三方代码可以看到某一个 <code>eval()</code> 被调用时的作用域,这也有可能导致一些不同方式的攻击。相似的 {{jsxref("Global_Objects/Function", "Function")}} 就不容易被攻击。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html index 5bad3a497f..490ed5e8b7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/evalerror/index.html @@ -7,11 +7,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/EvalError <p>本对象代表了一个关于 <a href="/en/Core_JavaScript_1.5_Reference/Global_Functions/eval" title="en/Core_JavaScript_1.5_Reference/Global_Functions/eval">eval</a> 函数的错误.此异常不再会被JavaScript抛出,但是EvalError对象仍然保持兼容性.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>new EvalError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt>message</dt> @@ -28,14 +28,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/EvalError <dd>可选参数.代码中导致异常的代码的行号.</dd> </dl> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt><a href="/en/Core_JavaScript_1.5_Reference/Global_Objects/EvalError/prototype" title="en/Core_JavaScript_1.5_Reference/Global_Objects/EvalError/prototype">prototype</a></dt> <dd>允许向EvalError对象中添加自定义属性.</dd> </dl> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <p>全局的EvalError对象本身不包含任何方法, 然而它通过原型链继承了一些方法.</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/float32array/index.html b/files/zh-cn/web/javascript/reference/global_objects/float32array/index.html index 016faed724..8acfb7feee 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/float32array/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/float32array/index.html @@ -43,7 +43,7 @@ new Float32Array(buffer [, byteOffset [, length]]);</pre> <dd>用可变数量的参数创建一个新的Float32Array。 参见 {{jsxref("Array.of()")}}。</dd> </dl> -<h2 id="Boolean_instances" name="Boolean_instances"><code>Float32Array</code> 属性</h2> +<h2 id="Boolean_instances"><code>Float32Array</code> 属性</h2> <p>所有的<code>Float32Array对象都</code>继承自 {{jsxref("TypedArray.prototype", "%TypedArray%.prototype")}}。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/apply/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/apply/index.html index 89706614c4..67a69174e6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/apply/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/apply/index.html @@ -17,11 +17,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>func</em>.apply(<em>thisArg</em><em>, [</em><em>argsArray</em>])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>thisArg</code></dt> @@ -34,7 +34,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply <p>调用有指定<code><strong>this</strong></code>值和参数的函数的结果。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>在调用一个存在的函数时,你可以为其指定一个 <code>this</code> 对象。 <code>this</code> 指当前对象,也就是正在调用这个函数的对象。 使用 <code>apply</code>, 你可以只写一次这个方法然后在另一个对象中继承它,而不用在新对象中重复写该方法。</p> @@ -48,7 +48,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply <p>需要注意:Chrome 14 以及 Internet Explorer 9 仍然不接受类数组对象。如果传入类数组对象,它们会抛出异常。</p> </div> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="用_apply_将数组各项添加到另一个数组">用 <code>apply</code> 将数组各项添加到另一个数组</h3> @@ -64,7 +64,7 @@ array.push.apply(array, elements); console.info(array); // ["a", "b", 0, 1, 2] </pre> -<h3 id="apply_and_built-in_functions" name="apply_and_built-in_functions">使用<code>apply</code>和内置函数</h3> +<h3 id="apply_and_built-in_functions">使用<code>apply</code>和内置函数</h3> <p>对于一些需要写循环以遍历数组各项的需求,我们可以用<code>apply</code>完成以避免循环。</p> @@ -106,7 +106,7 @@ for (var i = 0; i < numbers.length; i++) { var min = minOfArray([5, 6, 2, 3, 7]); </pre> -<h3 id="Using_apply_to_chain_constructors" name="Using_apply_to_chain_constructors">使用apply来链接构造器</h3> +<h3 id="Using_apply_to_chain_constructors">使用apply来链接构造器</h3> <p>你可以使用apply来链接一个对象<a href="/zh-CN/docs/JavaScript/Reference/Operators/new" title="JavaScript/Reference/Operators/new">构造器</a>,类似于Java。在接下来的例子中我们会创建一个全局<a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Function" title="JavaScript/Reference/Global_Objects/Function"><code>Function</code></a> 对象的construct方法 ,来使你能够在构造器中使用一个类数组对象而非参数列表。</p> @@ -204,7 +204,7 @@ console.log(myInstance.constructor); // logs "MyConstructor" <p>{{Compat("javascript.builtins.Function.apply")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Functions_and_function_scope/arguments", "arguments ")}} object</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/call/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/call/index.html index 5962c181a0..9474d40416 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/call/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/call/index.html @@ -165,7 +165,7 @@ display.call(); // Cannot read the property of 'sData' of undefined</pre> <p>{{Compat("javascript.builtins.Function.call")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Function.prototype.bind()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/caller/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/caller/index.html index ba3ce01a26..c3394dee07 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/caller/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/caller/index.html @@ -5,19 +5,19 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/caller --- <div>{{JSRef("Global_Objects", "Function")}} {{non-standard_header}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p>返回调用指定函数的函数.</p> <p>该属性不是ECMA-262第3版标准的一部分.不过, <a href="/zh-cn/SpiderMonkey" title="zh-cn/SpiderMonkey">SpiderMonkey</a> (Mozilla的JavaScript引擎) (查看{{ Bug("65683") }}), V8 (Chrome的JavaScript引擎) 和 JScript(IE的ECMAScript实现)都已经支持了它.</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果一个函数<code>f</code>是在全局作用域内被调用的,则<code>f.caller为</code><code>null</code>,相反,如果一个函数是在另外一个函数作用域内被调用的,则<code>f.caller指向调用它的那个函数.</code></p> <p>该属性的常用形式<code>arguments.callee.caller</code>替代了被废弃的 <a href="/zh-cn/JavaScript/Reference/Functions_and_function_scope/arguments/caller" title="zh-cn/JavaScript/Reference/Functions_and_function_scope/arguments/caller">arguments.caller</a>.</p> -<h3 id="Notes" name="Notes">备注</h3> +<h3 id="Notes">备注</h3> <p>注意,在使用递归调用时, 你不能使用此属性来重现出调用栈.请考虑以下代码:</p> @@ -50,9 +50,9 @@ while (f) { <p>有一个特殊属性 <code>__caller__</code>, 可以返回调用当前函数的函数的活动对象(可以用来重现出整个调用栈), 但由于安全原因的考虑,该属性已被删除.</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Checking_the_value_of_a_function.27s_caller_property" name="Example:_Checking_the_value_of_a_function.27s_caller_property">例子: 检测一个函数的<code>caller</code>属性的值</h3> +<h3 id="Example:_Checking_the_value_of_a_function.27s_caller_property">例子: 检测一个函数的<code>caller</code>属性的值</h3> <p>下例用来得出一个函数是被谁调用的<code>.</code></p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/length/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/length/index.html index 42532bd8ad..699cce5844 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/length/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/length/index.html @@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/length <div>{{js_property_attributes(0,0,1)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>length</code> 是函数对象的一个属性值,指该函数期望传入的参数数量,即形参的个数。</p> @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/length <p> {{jsxref("Function.prototype")}} 对象的 length 属性值为 0 。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">console.log(Function.length); /* 1 */ diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/tosource/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/tosource/index.html index 5c4de38138..851e354fc7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/tosource/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/tosource/index.html @@ -7,21 +7,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/toSource <div>{{JSRef("Global_Objects", "Function")}} {{non-standard_header}}</div> </div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p>返回函数的源代码的字符串表示.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>function</var>.toSource(); Function.toSource(); </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>toSource方法返回下面的值</code>:</p> @@ -41,7 +41,7 @@ Function.toSource(); <p>该方法通常在引擎内部调用.你可以在调试的时候用该方法开查看一个函数的源代码.</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li><a href="/zh-CN/docs/JavaScript/Reference/Global_Objects/Function/toString" title="JavaScript/Reference/Global_Objects/Function/toString">toString</a></li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/tostring/index.html index 1ab33a0d1f..4095dfba6a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/tostring/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/toString <div>{{EmbedInteractiveExample("pages/js/function-tostring.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>function</var>.toString()</code></pre> @@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/toString <p>表示函数源代码的一个字符串</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Function")}}对象覆盖了从{{jsxref("Object")}}继承来的{{jsxref("Object.prototype.toString", "toString")}} 方法。对于用户定义的 {{jsxref("Function")}} 对象,<code>toString</code>方法返回一个字符串,其中包含用于定义函数的源文本段。</p> @@ -223,7 +223,7 @@ Function("a", "b")</pre> <li>从Firefox 38开始,<code>Function.prototype.toString()</code> 会对 {{jsxref("Proxy")}} 对象抛出异常 ({{bug(1100936)}})。</li> </ul> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.toString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/generator/index.html b/files/zh-cn/web/javascript/reference/global_objects/generator/index.html index 9efc414db4..b3b016d83a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/generator/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/generator/index.html @@ -117,7 +117,7 @@ console.log(it.next()); // throws StopIteration (as the generator is now close <p>{{Compat("javascript.builtins.Generator")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <h3 id="Legacy_generators">Legacy generators</h3> diff --git a/files/zh-cn/web/javascript/reference/global_objects/generator/next/index.html b/files/zh-cn/web/javascript/reference/global_objects/generator/next/index.html index e135b75afc..63d7f9a169 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/generator/next/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/generator/next/index.html @@ -15,11 +15,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Generator/next <p><code><strong>next</strong></code><strong><code>()</code></strong> 方法返回一个包含属性 <code>done</code> 和 <code>value</code> 的对象。该方法也可以通过接受一个参数用以向生成器传值。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>gen</var>.next(value)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value</code></dt> @@ -43,7 +43,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Generator/next <h2 id="示例">示例</h2> -<h3 id="Example_Using_test" name="Example:_Using_test">使用 <code>next()方法</code></h3> +<h3 id="Example_Using_test">使用 <code>next()方法</code></h3> <p>下面的例子展示了一个简单的生成器, 以及调用 <code>next</code> 后方法的返回值:</p> @@ -79,7 +79,7 @@ g.next(2); // "{ value: null, done: false }"</code> </pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -101,7 +101,7 @@ g.next(2); </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div>{{CompatibilityTable}}</div> @@ -157,7 +157,7 @@ g.next(2); </div> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/function*">function*</a></code></li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/generator/return/index.html b/files/zh-cn/web/javascript/reference/global_objects/generator/return/index.html index 9c5ed4bb99..835495303e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/generator/return/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/generator/return/index.html @@ -14,11 +14,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Generator/return <p><code><strong>return</strong></code><strong><code>()</code></strong> 方法返回给定的值并结束生成器。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>gen</var>.return(value)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value</code></dt> @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Generator/return <h2 id="示例">示例</h2> -<h3 id="Example_Using_test" name="Example:_Using_test">使用 <code>return()</code></h3> +<h3 id="Example_Using_test">使用 <code>return()</code></h3> <p>以下例子展示了一个简单的生成器和 <code>return</code> 方法的使用.</p> @@ -64,7 +64,7 @@ g.next(); // { value: undefined, done: true } g.return(); // { value: undefined, done: true } g.return(1); // { value: 1, done: true }</pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -86,13 +86,13 @@ g.return(1); // { value: 1, done: true }</pre> </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <p>{{Compat("javascript.builtins.Generator.return")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/function*">function*</a></code></li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/generator/throw/index.html b/files/zh-cn/web/javascript/reference/global_objects/generator/throw/index.html index 19b2623a88..63afc5f965 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/generator/throw/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/generator/throw/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Generator/throw <p><code><strong>throw</strong></code><strong><code>()</code></strong> 方法用来向生成器抛出异常,并恢复生成器的执行,返回带有 <code>done</code> 及 <code>value</code> 两个属性的对象。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>gen</var>.throw(exception)</code></pre> @@ -42,7 +42,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Generator/throw <h2 id="示例">示例</h2> -<h3 id="Example:_Using_test" name="Example:_Using_test">使用 <code>throw()</code></h3> +<h3 id="Example:_Using_test">使用 <code>throw()</code></h3> <p>下面的例子展示了一个简单的生成器并使用 throw方法向该生成器抛出一个异常,该异常通常可以通过 <code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/try...catch">try...catch</a></code> 块进行捕获.</p> @@ -61,7 +61,7 @@ g.next(); // { value: 42, done: false } g.throw(new Error("Something went wrong")); // "Error caught!" </pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -83,7 +83,7 @@ g.throw(new Error("Something went wrong")); // "Error caught!" </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div>{{CompatibilityTable}}</div> @@ -135,7 +135,7 @@ g.throw(new Error("Something went wrong")); // "Error caught!" </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><code><a href="/en-US/docs/Web/JavaScript/Reference/Statements/function*">function*</a></code></li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/generatorfunction/index.html b/files/zh-cn/web/javascript/reference/global_objects/generatorfunction/index.html index afa1c2ac8c..379b31a804 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/generatorfunction/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/generatorfunction/index.html @@ -19,11 +19,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/GeneratorFunction <pre class="brush: js">Object.getPrototypeOf(function*(){}).constructor </pre> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>new GeneratorFunction ([<var>arg1</var>[, <var>arg2</var>[, ...<var>argN</var>]],] <var>functionBody</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>arg1, arg2, ... arg<em>N</em></code></dt> @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/GeneratorFunction <dd>一个包含多条表示JavaScript函数体语句的字符串。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>当创建函数时,将使用<code>GeneratorFunction</code>构造函数创建的{{jsxref("Statements/function*", "生成器函数")}}对象进行解析。这比使用{{jsxref("Statements/function*", "function* 表达式")}} 声明生成器函数效率更低,并且在代码中调用它,因为这些函数与其余的代码一起被解析。</p> @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/GeneratorFunction <p>将<code>GeneratorFunction</code>构造函数调用为函数(不使用<code>new</code>运算符)与将其作为构造函数调用的效果相同。</p> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt><code><strong>GeneratorFunction.length</strong></code></dt> @@ -59,11 +59,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/GeneratorFunction <div>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction/prototype', 'Properties')}}</div> -<h2 id="GeneratorFunction_instances" name="GeneratorFunction_instances"><code>GeneratorFunction</code> 实例</h2> +<h2 id="GeneratorFunction_instances"><code>GeneratorFunction</code> 实例</h2> <p><code>GeneratorFunction</code>实例从{{jsxref("GeneratorFunction.prototype")}}继承方法和属性。与所有构造函数一样,你可以更改构造函数的原型对象以对所有<code>GeneratorFunction</code>实例进行更改。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="从GeneratorFunction构造函数创建一个生成器函数">从<code>GeneratorFunction</code>构造函数创建一个生成器函数</h3> @@ -99,7 +99,7 @@ console.log(iterator.next().value); // 20 <p>{{Compat("javascript.builtins.GeneratorFunction")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Statements/function*", "function* function")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/infinity/index.html b/files/zh-cn/web/javascript/reference/global_objects/infinity/index.html index 929985516d..a0ce09c381 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/infinity/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/infinity/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Infinity <p>{{EmbedInteractiveExample("pages/js/globalprops-infinity.html")}}</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>Infinity</code> 是<em>全局对象</em>(<em>global object</em>)的一个属性,即它是一个全局变量。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/isfinite/index.html b/files/zh-cn/web/javascript/reference/global_objects/isfinite/index.html index cea70e68ee..f033320715 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/isfinite/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/isfinite/index.html @@ -16,14 +16,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isFinite <pre class="syntaxbox language-html">isFinite(<em>testValue</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>testValue</code></dt> <dd>用于检测有限性(finiteness)的值。</dd> </dl> -<h3 id="Description" name="Description">描述</h3> +<h3 id="Description">描述</h3> <dl> <dd>isFinite 是全局的方法,不与任何对象有关系。</dd> @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isFinite <p>你可以用这个方法来判定一个数字是否是有限数字。<code>isFinite</code> 方法检测它参数的数值。如果参数是 <code>NaN</code>,正无穷大或者负无穷大,会返回<code>false</code>,其他返回 <code>true</code>。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js language-js">isFinite(Infinity); // false isFinite(NaN); // false @@ -97,7 +97,7 @@ isFinite("0"); // true, 在更强壮的Number.isFinite('0')中将会得到 <p>{{Compat("javascript.builtins.isFinite")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Number.isFinite()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/isnan/index.html b/files/zh-cn/web/javascript/reference/global_objects/isnan/index.html index 1e23c1d0e4..00704c3228 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/isnan/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/isnan/index.html @@ -13,11 +13,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isNaN <p>{{EmbedInteractiveExample("pages/js/globalprops-isnan.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>isNaN(value)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value</code></dt> @@ -28,13 +28,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isNaN <p>如果给定值为 {{jsxref("NaN")}}则返回值为<code>true</code>;否则为<code>false</code>。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> -<h3 id="The_necessity_of_an_isNaN_function" name="The_necessity_of_an_isNaN_function"><code>isNaN</code> 函数的必要性</h3> +<h3 id="The_necessity_of_an_isNaN_function"><code>isNaN</code> 函数的必要性</h3> <p>与 JavaScript 中其他的值不同,{{jsxref("Global_Objects/NaN", "NaN")}}不能通过相等操作符(== 和 ===)来判断 ,因为 <code>NaN == NaN</code> 和 <code>NaN === NaN</code> 都会返回 <code>false</code>。 因此,<code>isNaN</code> 就很有必要了。</p> -<h3 id="Origin_of_NaN_values" name="Origin_of_NaN_values"><code>NaN值</code>的产生</h3> +<h3 id="Origin_of_NaN_values"><code>NaN值</code>的产生</h3> <p>当算术运算返回一个未定义的或无法表示的值时,<code>NaN</code>就产生了。但是,<code>NaN</code>并不一定用于表示某些值超出表示范围的情况。将某些不能强制转换为数值的非数值转换为数值的时候,也会得到<code>NaN</code>。</p> @@ -53,7 +53,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isNaN return n !== n; };</pre> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">isNaN(NaN); // true isNaN(undefined); // true diff --git a/files/zh-cn/web/javascript/reference/global_objects/json/index.html b/files/zh-cn/web/javascript/reference/global_objects/json/index.html index cbacf78288..2afd07d205 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/json/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/json/index.html @@ -13,9 +13,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/JSON <p><strong><code>JSON</code></strong>对象包含两个方法: 用于解析 <a class="external" href="http://json.org/">JavaScript Object Notation</a> ({{glossary("JSON")}}) 的 <code>parse()</code> 方法,以及将对象/值转换为 JSON字符串的 <code>stringify()</code> 方法。除了这两个方法, JSON这个对象本身并没有其他作用,也不能被调用或者作为构造函数调用。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> -<h3 id="JavaScript_Object_Notation" name="JavaScript_Object_Notation">JavaScript Object Notation</h3> +<h3 id="JavaScript_Object_Notation">JavaScript Object Notation</h3> <p><strong>JSON</strong> 是一种语法,用来序列化对象、数组、数值、字符串、布尔值和 {{jsxref("null")}} 。它基于 JavaScript 语法,但与之不同:<strong>JavaScript不是JSON,JSON也不是JavaScript</strong>。参考 <a href="http://timelessrepo.com/json-isnt-a-javascript-subset">JSON:并不是JavaScript 的子集</a>。</p> @@ -106,7 +106,7 @@ ArrayElements = JSON <p>在<code>JSONNumber</code>(数字内部不允许包含空格)或<code>JSONString</code>(字符串内部的空格被解释为相应的字符,否则就有问题了)之外的任何位置可以有多余的空白字符。JSON只支持这些空白字符: 制表符(<a href="http://unicode-table.com/en/0009/">U+0009</a>),回车(<a href="http://unicode-table.com/en/000D/">U+000D</a>),换行(<a href="http://unicode-table.com/en/0020/">U+00</a>0A)以及空格(<a href="http://unicode-table.com/en/0020/">U+0020</a>)。</p> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <dl> <dt>{{jsxref("JSON.parse()")}}</dt> @@ -115,7 +115,7 @@ ArrayElements = JSON <dd>返回与指定值对应的JSON字符串,可以通过额外的参数, 控制仅包含某些属性, 或者以自定义方法来替换某些key对应的属性值。</dd> </dl> -<h2 id="Polyfill" name="Polyfill">Polyfill</h2> +<h2 id="Polyfill">Polyfill</h2> <p><code>JSON</code>对象可能不被老版本的浏览器支持。可以将下面的代码放到JS脚本最开始的位置,这样就可以在没有原生支持 JSON 对象的浏览器(如IE6)中使用 <code>JSON</code>对象。</p> @@ -163,7 +163,7 @@ ArrayElements = JSON <p>业界更专业, 更强大的<code>JSON</code>对象 <a class="external" href="http://remysharp.com/2010/10/08/what-is-a-polyfill/" title="http://remysharp.com/2010/10/08/what-is-a-polyfill/">polyfills</a> 是 <a class="link-https" href="https://github.com/douglascrockford/JSON-js" title="https://github.com/douglascrockford/JSON-js">JSON2</a> 和 <a class="external" href="http://bestiejs.github.com/json3" title="http://bestiejs.github.com/json3">JSON3</a>。</p> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -190,11 +190,11 @@ ArrayElements = JSON </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <p>{{Compat("javascript.builtins.JSON")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Date.prototype.toJSON()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/json/stringify/index.html b/files/zh-cn/web/javascript/reference/global_objects/json/stringify/index.html index ac4e1cdd67..e37a4fc9ee 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/json/stringify/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/json/stringify/index.html @@ -17,12 +17,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/JSON/stringify <p>{{EmbedInteractiveExample("pages/js/json-stringify.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>JSON.stringify(<em>value</em>[, <em>replacer</em> [, <em>space</em>]])</code> </pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value</code></dt> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/abs/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/abs/index.html index 397ad9724b..e86e8064c2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/abs/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/abs/index.html @@ -9,24 +9,24 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/abs <p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mrow><mo lspace="0em" rspace="thinmathspace">Math.abs</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle><mo>=</mo><mrow><mo stretchy="false">|</mo><mi>x</mi><mo stretchy="false">|</mo></mrow><mo>=</mo><mrow><mo>{</mo><mtable columnalign="left left"><mtr><mtd><mi>x</mi></mtd><mtd><mtext>if</mtext><mspace width="1em"></mspace><mi>x</mi><mo>≥</mo><mn>0</mn></mtd></mtr><mtr><mtd><mo>-</mo><mi>x</mi></mtd><mtd><mtext>if</mtext><mspace width="1em"></mspace><mi>x</mi><mo><</mo><mn>0</mn></mtd></mtr></mtable></mrow></mrow><annotation encoding="TeX">{\mathtt{\operatorname{Math.abs}(x)}} = {|x|} = \begin{cases} x & \text{if} \quad x \geq 0 \\ -x & \text{if} \quad x < 0 \end{cases} </annotation></semantics></math></p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.abs(<em>x</em>);</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>一个数值</dd> </dl> -<h2 id="Description" name="Description">说明</h2> +<h2 id="Description">说明</h2> <p><code>由于 Math.abs()</code> <code>是</code> <code>Math</code> 中的一个静态方法,你应该通过 <code>Math.abs()</code> <code>调用。</code>(Math 不是构造器)</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Math.abs_behavior" name="Example:_Math.abs_behavior"><code>Math.abs()函数的行为</code></h3> +<h3 id="Example:_Math.abs_behavior"><code>Math.abs()函数的行为</code></h3> <p>传入一个非数字形式的字符串或者 undefined/empty 变量,将返回 <code>NaN</code>。传入 null 将返回 0。</p> @@ -115,7 +115,7 @@ Math.abs(); // NaN</pre> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/acos/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/acos/index.html index 032174b53e..b50eb69568 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/acos/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/acos/index.html @@ -5,23 +5,23 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/acos --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.acos()</strong></code> 返回一个数的反余弦值(单位为弧度),即:</p> <p><math display="block"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>∊</mo><mo stretchy="false">[</mo><mrow><mo>-</mo><mn>1</mn></mrow><mo>;</mo><mn>1</mn><mo stretchy="false">]</mo><mo>,</mo><mspace width="thickmathspace"></mspace><mstyle mathvariant="monospace"><mrow><mo lspace="0em" rspace="thinmathspace">Math.acos</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle><mo>=</mo><mo lspace="0em" rspace="0em">arccos</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width="thickmathspace"></mspace><mi>y</mi><mo>∊</mo><mo stretchy="false">[</mo><mn>0</mn><mo>;</mo><mi>π</mi><mo stretchy="false">]</mo><mspace width="thinmathspace"></mspace><mtext>such that</mtext><mspace width="thickmathspace"></mspace><mo lspace="0em" rspace="0em">cos</mo><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding="TeX">\forall x \in [{-1};1],\;\mathtt{\operatorname{Math.acos}(x)} = \arccos(x) = \text{ the unique } \; y \in [0; \pi] \, \text{such that} \; \cos(y) = x</annotation></semantics></math></p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.acos(<em>x</em>) </pre> -<h2 id="Parameters" name="Parameters">参数</h2> +<h2 id="Parameters">参数</h2> <dl> <dt> <code>x</code></dt> <dd> 一个数值</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>acos</code> 方法以 -1 到 1 的一个数为参数,返回一个 0 到 pi (弧度)的数值。如果传入的参数值超出了限定的范围,将返回 <code>NaN</code>。</p> <p>由于 <code>acos</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.acos()</code>,而不是作为你创建的 <code>Math</code> 实例的属性(<code>Math</code> 不是一个构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.acos" name="Example:_Using_Math.acos">例子:使用 <code>Math.acos</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.acos">例子:使用 <code>Math.acos</code></h3> <pre class="brush:js">Math.acos(-2); // NaN Math.acos(-1); // 3.141592653589793 Math.acos(0); // 1.5707963267948966 @@ -103,7 +103,7 @@ Math.acos(2); // NaN </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> <li>{{jsxref("Math.asin()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/asin/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/asin/index.html index 7e6017abbd..2386375e80 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/asin/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/asin/index.html @@ -5,23 +5,23 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/asin --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.asin()</strong></code> 方法返回一个数值的反正弦(单位为弧度),即:</p> <p><math display="block"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>∊</mo><mo stretchy="false">[</mo><mrow><mo>-</mo><mn>1</mn></mrow><mo>;</mo><mn>1</mn><mo stretchy="false">]</mo><mo>,</mo><mspace width="thickmathspace"></mspace><mstyle mathvariant="monospace"><mrow><mo lspace="0em" rspace="thinmathspace">Math.asin</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle><mo>=</mo><mo lspace="0em" rspace="0em">arcsin</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width="thickmathspace"></mspace><mi>y</mi><mo>∊</mo><mrow><mo>[</mo><mrow><mo>-</mo><mfrac><mi>π</mi><mn>2</mn></mfrac><mo>;</mo><mfrac><mi>π</mi><mn>2</mn></mfrac></mrow><mo>]</mo></mrow><mspace width="thinmathspace"></mspace><mtext>such that</mtext><mspace width="thickmathspace"></mspace><mo lspace="0em" rspace="0em">sin</mo><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding="TeX">\forall x \in [{-1};1],\;\mathtt{\operatorname{Math.asin}(x)} = \arcsin(x) = \text{ the unique } \; y \in \left[-\frac{\pi}{2}; \frac{\pi}{2}\right] \, \text{such that} \; \sin(y) = x</annotation></semantics></math></p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.asin(<em>x</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt> <code>x</code></dt> <dd> 一个数值</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>asin</code> 方法接受 -1 到 1 之间的数值作为参数,返回一个介于 <math><semantics><mrow><mo>-</mo><mfrac><mi>π</mi><mn>2</mn></mfrac></mrow><annotation encoding="TeX">-\frac{\pi}{2}</annotation></semantics></math> 到 <math><semantics><mfrac><mi>π</mi><mn>2</mn></mfrac><annotation encoding="TeX">\frac{\pi}{2}</annotation></semantics></math> 弧度的数值。如果接受的参数值超出范围,则返回 <code>NaN</code>。</p> <p>由于 <code>asin</code> 是 <code>Math</code> 的静态方法,所有应该像这样使用:<code>Math.asin()</code>,而不是作为你创建的 <code>Math</code> 实例的方法。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.asin" name="Example:_Using_Math.asin">例子:使用 <code>Math.asin()</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.asin">例子:使用 <code>Math.asin()</code></h3> <pre class="brush:js">Math.asin(-2); // NaN Math.asin(-1); // -1.5707963267948966 (-pi/2) Math.asin(0); // 0 @@ -102,7 +102,7 @@ Math.asin(2); // NaN</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> <li>{{jsxref("Math.acos()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/atan/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/atan/index.html index 460bd0de51..0bdf09d234 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/atan/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/atan/index.html @@ -5,23 +5,23 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.atan()</strong></code> 函数返回一个数值的反正切(以弧度为单位),即:</p> <p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mrow><mo lspace="0em" rspace="thinmathspace">Math.atan</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle><mo>=</mo><mo lspace="0em" rspace="0em">arctan</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width="thickmathspace"></mspace><mi>y</mi><mo>∊</mo><mrow><mo>[</mo><mrow><mo>-</mo><mfrac><mi>π</mi><mn>2</mn></mfrac><mo>;</mo><mfrac><mi>π</mi><mn>2</mn></mfrac></mrow><mo>]</mo></mrow><mspace width="thinmathspace"></mspace><mtext>such that</mtext><mspace width="thickmathspace"></mspace><mo lspace="0em" rspace="0em">tan</mo><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding="TeX">\mathtt{\operatorname{Math.atan}(x)} = \arctan(x) = \text{ the unique } \; y \in \left[-\frac{\pi}{2}; \frac{\pi}{2}\right] \, \text{such that} \; \tan(y) = x</annotation></semantics></math></p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.atan(<em>x</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt> <code>x</code></dt> <dd> 一个数值</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>atan</code> 返回一个 <math><semantics><mrow><mo>-</mo><mfrac><mi>π</mi><mn>2</mn></mfrac></mrow><annotation encoding="TeX">-\frac{\pi}{2}</annotation></semantics></math> 到 <math><semantics><mfrac><mi>π</mi><mn>2</mn></mfrac><annotation encoding="TeX">\frac{\pi}{2}</annotation></semantics></math> 弧度之间的数值。</p> <p>由于 <code>atan</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.atan()</code>,而不是作为你创建的 <code>Math</code> 实例的方法。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.atan" name="Example:_Using_Math.atan">例子:使用 <code>Math.atan</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.atan">例子:使用 <code>Math.atan</code></h3> <pre class="brush:js">Math.atan(1); // 0.7853981633974483 Math.atan(0); // 0 </pre> @@ -98,7 +98,7 @@ Math.atan(0); // 0 </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> <li>{{jsxref("Math.acos()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/atan2/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/atan2/index.html index 64064017c7..b4ded024ac 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/atan2/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/atan2/index.html @@ -5,22 +5,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan2 --- <div>{{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.atan2(</strong></code><code><strong>)</strong></code> 返回从原点(0,0)到(x,y)点的线段与x轴正方向之间的平面角度(弧度值),也就是Math.atan2(y,x)</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.atan2(<em>y</em>, <em>x</em>) </pre> -<h2 id="Parameters" name="Parameters">参数</h2> +<h2 id="Parameters">参数</h2> <dl> <dt><code>y, x</code></dt> <dd>数值</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>atan2</code> 方法返回一个 -pi 到 pi 之间的数值,表示点 (x, y) 对应的偏移角度。这是一个逆时针角度,以弧度为单位,正X轴和点 (x, y) 与原点连线 之间。注意此函数接受的参数:先传递 y 坐标,然后是 x 坐标。</p> @@ -28,9 +28,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan2 <p>由于 <code>atan2</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.atan2()</code>,而不是作为你创建的 <code>Math</code> 实例的方法。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_Math.atan2" name="Example:_Using_Math.atan2">例子:使用 <code>Math.atan2</code></h3> +<h3 id="Example_Using_Math.atan2">例子:使用 <code>Math.atan2</code></h3> <pre class="brush:js">Math.atan2(90, 15) // 1.4056476493802699 Math.atan2(15, 90) // 0.16514867741462683 @@ -127,7 +127,7 @@ Math.atan2(15, 90) // 0.16514867741462683 </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/cbrt/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/cbrt/index.html index 22f37c402a..506e303660 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/cbrt/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/cbrt/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/cbrt --- <div>{{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.cbrt()</strong></code> 函数返回任意数字的立方根.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.cbrt(<em>x</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/cbrt -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>该方法为Math的静态方法,因此请直接通过Math.cbrt()方式调用.</p> @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/cbrt <p>cbrt 是 "cube root" 的缩写, 意思是立方根.</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="使用_Math.cbrt">使用 Math.cbrt()</h3> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/clz32/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/clz32/index.html index 6112c6e45e..20139dec2f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/clz32/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/clz32/index.html @@ -5,16 +5,16 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/clz32 --- <div>{{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.clz32() </strong></code>函数返回一个数字在转换成 32 无符号整形数字的二进制形式后, 开头的 0 的个数, 比如 <code>1000000</code> 转换成 32 位无符号整形数字的二进制形式后是 <code>00000000000011110100001001000000</code>, 开头的 0 的个数是 12 个, 则 <code>Math.clz32(1000000)</code> 返回 <code>12</code>.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.clz32 (x) </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt>x</dt> @@ -45,7 +45,7 @@ Math.clz32(true) // 31 Math.clz32(3.5) // 30 </pre> -<h2 id="Compatibility" name="Compatibility">计算前导1的个数</h2> +<h2 id="Compatibility">计算前导1的个数</h2> <p>目前javascript尚未提供<code>Math.clon</code>函数来计算前导1的个数(之所以叫“clon”而非“clo”,是因为“clo”与“clz”太过相似,特别对那些母语不是英语的人来说),但是你可以通过将一个数取反并将其作为<code>Math.clz32</code>的参数来实现clon函数。其中的原理非常简单,因为对1取反是0,反之亦然,所以用<code>Math.clz32</code>计算前导0的个数就变成计算前导1的个数。</p> @@ -122,7 +122,7 @@ function ctron(integer){ // 计算尾随1个数 var ctrz = countTrailsMethods.a; var ctron = countTrailsMethods.b;</pre> -<h2 id="Compatibility" name="Compatibility">Polyfill</h2> +<h2 id="Compatibility">Polyfill</h2> <p>这个polyfill效率最高。</p> @@ -157,7 +157,7 @@ var ctron = countTrailsMethods.b;</pre> <p>{{Compat("javascript.builtins.Math.clz32")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Math")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/cos/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/cos/index.html index 482f2fa09a..d0741e46a4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/cos/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/cos/index.html @@ -5,22 +5,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/cos --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.cos()</strong></code> 函数返回一个数值的余弦值。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.cos(<em>x</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt> <code>x</code></dt> <dd> 一个以弧度为单位的数值。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>cos</code> 方法返回一个 -1 到 1 之间的数值,表示角度(单位:弧度)的余弦值。</p> <p>由于 <code>cos</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.cos()</code>,而不是作为你创建的 <code>Math</code> 实例的方法。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.cos" name="Example:_Using_Math.cos">例子:使用 <code>Math.cos</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.cos">例子:使用 <code>Math.cos</code></h3> <pre class="brush:js">Math.cos(0); // 1 Math.cos(1); // 0.5403023058681398 @@ -100,7 +100,7 @@ Math.cos(2 * Math.PI); // 1 </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/e/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/e/index.html index 2a0afca6ab..adb71b9f29 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/e/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/e/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/E --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.E</strong></code> 属性表示自然对数的底数(或称为基数),e,约等于 2.718。</p> <p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mi>Math.E</mi></mstyle><mo>=</mo><mi>e</mi><mo>≈</mo><mn>2.718</mn></mrow><annotation encoding="TeX">\mathtt{\mi{Math.E}} = e \approx 2.718</annotation></semantics></math></p> <div> {{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>E</code> 是 <code>Math</code> 对象的静态属性,所以应该像这样使用:<code>Math.E</code>,而不是作为你创建的 <code>Math</code> 实例对象的属性(<code>Math</code> 不是构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.E" name="Example:_Using_Math.E">例子:使用 <code>Math.E</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.E">例子:使用 <code>Math.E</code></h3> <p>下面的函数返回 e:</p> <pre class="brush:js">function getNapier() { return Math.E @@ -93,7 +93,7 @@ getNapier() // 2.718281828459045</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/exp/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/exp/index.html index 0da94f62c2..14f5af47c3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/exp/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/exp/index.html @@ -5,21 +5,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/exp --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.exp()</strong></code> 函数返回 <code>e<sup>x</sup></code>,<code>x</code> 表示参数,<code>e</code> 是<a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Math/E">欧拉常数(Euler's constant)</a>,自然对数的底数。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.exp(<em>x</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt> <code>x</code></dt> <dd> 一个数值</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>exp</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.exp()</code>,而不是作为你创建的 <code>Math</code> 实例的方法。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.exp" name="Example:_Using_Math.exp">例子:使用 <code>Math.exp</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.exp">例子:使用 <code>Math.exp</code></h3> <pre class="brush:js">Math.exp(-1); // 0.36787944117144233 Math.exp(0); // 1 Math.exp(1); // 2.718281828459045</pre> @@ -96,7 +96,7 @@ Math.exp(1); // 2.718281828459045</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> <li>{{jsxref("Math.E")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/expm1/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/expm1/index.html index ff321fb664..0fd773ece9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/expm1/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/expm1/index.html @@ -5,28 +5,28 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/expm1 --- <div>{{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.expm1()</strong></code> 函数返回 <code>E<sup>x</sup> - 1</code>, 其中 <code>x</code> 是该函数的参数, <code>E</code> 是自然对数的底数 <code>2.718281828459045.</code></p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.expm1(<em>x</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>任意数字.</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>参数 <code>x</code> 会被自动类型转换成 <code>number </code>类型.</code></p> <p><code>expm1 是 "exponent minus 1" 的缩写.</code></p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush:js">Math.expm1(1) // 1.7182818284590453 Math.expm1(-38) // -1 @@ -112,7 +112,7 @@ Math.expm1("foo") // NaN </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/Math", "Math")}} 对象.</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/floor/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/floor/index.html index 84f4f3b8b6..3f9deb45c0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/floor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/floor/index.html @@ -15,11 +15,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/floor <p>Note: 可以理解 <code><strong>Math.floor()</strong></code>为向下取整</p> </div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.floor(<em>x</em>) </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> @@ -31,13 +31,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/floor </dt> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>floor</code> 是 <code>Math</code> 的一个静态方法,你总是应该像这样使用它 <code>Math.floor()</code>,而不是作为你创建的一个Math对象的一种方法(Math不是一个构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_Math.floor" name="Example:_Using_Math.floor">例子:使用 <code>Math.floor</code></h3> +<h3 id="Example_Using_Math.floor">例子:使用 <code>Math.floor</code></h3> <pre class="brush:js">Math.floor( 45.95); // 45 @@ -52,7 +52,7 @@ Math.floor(-45.95); </pre> -<h3 id="Example_Decimal_adjustment" name="Example:_Decimal_adjustment">例子:十进制调整</h3> +<h3 id="Example_Decimal_adjustment">例子:十进制调整</h3> <pre class="brush:js">// Closure (function(){ @@ -210,7 +210,7 @@ Math.ceil10(-59, 1); // -50 </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/fround/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/fround/index.html index f5118b4a22..b4790b6448 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/fround/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/fround/index.html @@ -5,26 +5,26 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/fround --- <div>{{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><strong><code>Math.fround()</code></strong> 可以将任意的数字转换为离它最近的<a class="external" href="https://en.wikipedia.org/wiki/Single-precision_floating-point_format" title="link to the wikipedia page on single-precision floating-point format">单精度浮点数</a>形式的数字。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="brush: js"><code>Math.fround(<var>doubleFloat</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>doubleFloat</code></dt> <dd>一个 {{jsxref("Number")}}。若参数为非数字类型,则会被转投成数字。无法转换时,设置成{{jsxref("NaN")}}。</dd> </dl> -<h3 id="Parameters" name="Parameters">返回值</h3> +<h3 id="Parameters">返回值</h3> <p>指定数字最接近的<a href="https://en.wikipedia.org/wiki/Single-precision_floating-point_format">32位单精度</a>浮点数表示。</p> -<h2 id="Examples" name="Examples">描述</h2> +<h2 id="Examples">描述</h2> <p>JavaScript 内部使用64位的双浮点数字,支持很高的精度。但是,有时你需要用32位浮点数字,比如你从一个{{jsxref("Float32Array")}} 读取值时。这时会产生混乱:检查一个64位浮点数和一个32位浮点数是否相等会失败,即使二个数字几乎一模一样。</p> @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/fround <p>因为<code>fround()</code> 是<code>Math</code> 的静态方法,你必须通过 <code>Math.fround()</code> 来使用,而不是调用你创建的<code>Math</code> 对象的一个实例方法(<code>Math</code>不是一个构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="使用_Math.fround()">使用 Math.fround()</h3> @@ -70,7 +70,7 @@ function equal(v1, v2) { equal(0.1 + 0.2, 0.3); //true </pre> -<h2 id="Polyfill" name="Polyfill">Polyfill</h2> +<h2 id="Polyfill">Polyfill</h2> <p>下面的函数可以模拟这个 API,前提是浏览器必须已经支持 {{jsxref("Float32Array")}}:</p> @@ -80,7 +80,7 @@ equal(0.1 + 0.2, 0.3); //true }; })(new Float32Array(1));</pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -95,7 +95,7 @@ equal(0.1 + 0.2, 0.3); //true </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div>{{CompatibilityTable}}</div> @@ -147,7 +147,7 @@ equal(0.1 + 0.2, 0.3); //true </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Math.round()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/hypot/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/hypot/index.html index dc368fddb6..844e2b0895 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/hypot/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/hypot/index.html @@ -17,11 +17,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/hypot -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.hypot([<em>value1</em>[,<em>value2</em>, ...]]) </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value1, value2, ...</code></dt> @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/hypot <p>将所提供的参数求平方和后开平方根。如果有参数不能转换为数字,则返回 {{jsxref("NaN")}}。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>计算直角三角形的斜边,或复数的幅值时可以使用函数 <code>Math.sqrt(v1*v1 + v2*v2)</code> ,其中 v1 和 v2 是三角形的两个直角边或复数的实部和虚部。如果想计算更多维度,那么只需要在后面添加更多的数的平方就可以了,比如 <code>Math.sqrt(v1*v1 + v2*v2 + v3*v3 + v4*v4)</code>。</p> @@ -48,7 +48,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/hypot <p>如果只传入一个参数, <code>Math.hypot(x)</code> 等同于 <code>Math.abs(x)</code>.</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="Using_Math.hypot">Using <code>Math.hypot()</code></h3> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/imul/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/imul/index.html index a3daf8f633..42c9565c28 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/imul/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/imul/index.html @@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/imul <pre class="syntaxbox"><code>var<em> product</em> = Math.imul(a, b)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>a</code></dt> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/ln10/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/ln10/index.html index a4eba0051e..763340918a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/ln10/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/ln10/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/LN10 --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.LN10</strong></code> 属性表示 10 的自然对数,约为 2.302:</p> <p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mi>Math.LN10</mi></mstyle><mo>=</mo><mo lspace="0em" rspace="0em">ln</mo><mo stretchy="false">(</mo><mn>10</mn><mo stretchy="false">)</mo><mo>≈</mo><mn>2.302</mn></mrow><annotation encoding="TeX">\mathtt{\mi{Math.LN10}} = \ln(10) \approx 2.302</annotation></semantics></math></p> <div> {{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>LN10</code> 是 <code>Math</code> 的静态属性,所以应该像这样使用:<code>Math.LN10</code>,而不是作为你创建的 <code>Math</code> 实例的属性(<code>Math</code> 不是构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.LN10" name="Example:_Using_Math.LN10">例子:使用 <code>Math.LN10</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.LN10">例子:使用 <code>Math.LN10</code></h3> <p>下面的函数返回 10 的自然对数:</p> <pre class="brush:js">function getNatLog10() { return Math.LN10 @@ -93,7 +93,7 @@ getNatLog10() // 2.302585092994046</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/ln2/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/ln2/index.html index b8d7dd049e..f1d8fd9c23 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/ln2/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/ln2/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/LN2 --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.LN2</strong></code> 属性表示 2 的自然对数,约为 0.693:</p> <p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mi>Math.LN2</mi></mstyle><mo>=</mo><mo lspace="0em" rspace="0em">ln</mo><mo stretchy="false">(</mo><mn>2</mn><mo stretchy="false">)</mo><mo>≈</mo><mn>0.693</mn></mrow><annotation encoding="TeX">\mathtt{\mi{Math.LN2}} = \ln(2) \approx 0.693</annotation></semantics></math></p> <div> {{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>LN2</code> 是 <code>Math</code> 的静态属性,所以应该像这样使用:<code>Math.LN2</code>,而不是作为你创建的 <code>Math</code> 实例的属性(<code>Math</code> 不是构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.LN2" name="Example:_Using_Math.LN2">例子:使用 <code>Math.LN2</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.LN2">例子:使用 <code>Math.LN2</code></h3> <p>下面的函数返回 2 的自然对数:</p> <pre class="brush:js">function getNatLog2() { return Math.LN2 @@ -93,7 +93,7 @@ getNatLog2() // 0.6931471805599453</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/log/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/log/index.html index 5be95016a8..fc1a647ccc 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/log/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/log/index.html @@ -5,24 +5,24 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/log --- <p>{{JSRef("Global_Objects", "Math")}}</p> -<h2 name="Summary">概述</h2> +<h2>概述</h2> <p><code><strong>Math.log()</strong></code> 函数返回一个数的自然对数,即:</p> <p><math><semantics><mrow><mo>∀</mo><mi>x</mi><mo>></mo><mn>0</mn><mo>,</mo><mstyle mathvariant="monospace"><mrow><mo lspace="0em" rspace="thinmathspace">Math.log</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle><mo>=</mo><mo lspace="0em" rspace="0em">ln</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mtext>the unique</mtext><mspace width="thickmathspace"></mspace><mi>y</mi><mspace width="thickmathspace"></mspace><mtext>such that</mtext><mspace width="thickmathspace"></mspace><msup><mi>e</mi><mi>y</mi></msup><mo>=</mo><mi>x</mi></mrow><annotation encoding="TeX">\forall x > 0, \mathtt{\operatorname{Math.log}(x)} = \ln(x) = \text{the unique} \; y \; \text{such that} \; e^y = x</annotation></semantics></math></p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.log(<em>x</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>一个数字.</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果指定的 <code>number</code> 为负数,则返回值为 <code>NaN</code>。</p> @@ -30,7 +30,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/log <h2 id="示例">示例</h2> -<h3 id="Example:_Using_Math.log" name="Example:_Using_Math.log">例子1:使用<code>Math.log</code></h3> +<h3 id="Example:_Using_Math.log">例子1:使用<code>Math.log</code></h3> <p>下面的函数返回指定变量的自然对数:</p> @@ -128,7 +128,7 @@ Math.log(10); // 2.302585092994046</pre> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <p></p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/log10/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/log10/index.html index 80dc91b6ca..1f6d67437a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/log10/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/log10/index.html @@ -7,26 +7,26 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/log10 <div>{{JSRef("Global_Objects", "Math")}}</div> </div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.log10()</strong></code> 函数返回一个数字以 10 为底的对数.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.log10(<em>x</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>任意数字.</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果传入的参数小于 0, 则返回 NaN.</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush:js">Math.log10(10) // 1 Math.log10(100) // 2 @@ -106,7 +106,7 @@ Math.log10("foo")// NaN </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/Math", "Math")}} 对象.</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/log10e/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/log10e/index.html index 1e5f1ae035..43e10e9ed5 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/log10e/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/log10e/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/LOG10E --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.LOG10E</strong></code> 属性表示以 10 为底数,e 的对数,约为 0.434:</p> <p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mi>Math.LOG10E</mi></mstyle><mo>=</mo><msub><mo lspace="0em" rspace="0em">log</mo><mn>10</mn></msub><mo stretchy="false">(</mo><mi>e</mi><mo stretchy="false">)</mo><mo>≈</mo><mn>0.434</mn></mrow><annotation encoding="TeX">\mathtt{\mi{Math.LOG10E}} = \log_10(e) \approx 0.434</annotation></semantics></math></p> <div> {{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>LOG10E</code> 是 <code>Math</code> 的静态属性,所以应该像这样使用:<code>Math.LOG10E</code>,而不是作为你创建的 <code>Math</code> 实例的属性(<code>Math</code> 不是一个构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.LOG10E" name="Example:_Using_Math.LOG10E">例子:使用 <code>Math.LOG10E</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.LOG10E">例子:使用 <code>Math.LOG10E</code></h3> <p>下面的函数返回以 10为底数,E的对数:</p> <pre class="brush:js">function getLog10e() { return Math.LOG10E @@ -93,7 +93,7 @@ getLog10e() // 0.4342944819032518</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/log1p/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/log1p/index.html index e80f580580..139283bc81 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/log1p/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/log1p/index.html @@ -7,22 +7,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/log1p <div>{{JSRef("Global_Objects", "Math")}}</div> </div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.log1p()</strong></code> 函数返回一个数字加1后的自然对数 (底为 <code>E</code>), 既<code>log(x+1)</code>.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.log1p(<em>x</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>任意数字.</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果参数的值小于<code> -1</code>, 则返回 <code>NaN.</code></p> @@ -109,7 +109,7 @@ Math.log1p("foo") // NaN </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/Math", "Math")}} 对象.</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/log2/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/log2/index.html index 78f1c43b93..1811e1b183 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/log2/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/log2/index.html @@ -7,26 +7,26 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/log2 <div>{{JSRef("Global_Objects", "Math")}}</div> </div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.log2()</strong></code> 函数返回一个数字以 2 为底的对数.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.log2(<em>x</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>任意数字.</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果传入的参数小于 0, 则返回 <code>NaN</code>.</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush:js">Math.log2(2) // 1 Math.log2(1024) // 10 @@ -106,7 +106,7 @@ Math.log2("foo") // NaN </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/Math", "Math")}} 对象.</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/log2e/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/log2e/index.html index 9ede75f09c..79f6800f6e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/log2e/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/log2e/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/LOG2E --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.LOG2E</strong></code> 属性表示以 2 为底数,e 的对数,约为 1.442:</p> <p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mi>Math.LOG2E</mi></mstyle><mo>=</mo><msub><mo lspace="0em" rspace="0em">log</mo><mn>2</mn></msub><mo stretchy="false">(</mo><mi>e</mi><mo stretchy="false">)</mo><mo>≈</mo><mn>1.442</mn></mrow><annotation encoding="TeX">\mathtt{\mi{Math.LOG2E}} = \log_2(e) \approx 1.442</annotation></semantics></math></p> <div> {{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>LOG2E</code> 是 <code>Math</code> 的静态属性,所以应该像这样使用:<code>Math.LOG2E</code>,而不是作为你创建的 <code>Math</code> 对象的属性(<code>Math</code> 不是一个构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.LOG2E" name="Example:_Using_Math.LOG2E">例子:使用 <code>Math.LOG2E</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.LOG2E">例子:使用 <code>Math.LOG2E</code></h3> <p>下面的函数返回以 2 为底数,E 的对数:</p> <pre class="brush:js">function getLog2e() { return Math.LOG2E @@ -93,7 +93,7 @@ getLog2e() // 1.4426950408889634</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/max/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/max/index.html index 593776318e..73e3914dce 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/max/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/max/index.html @@ -12,11 +12,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/max <p>{{EmbedInteractiveExample("pages/js/math-max.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.max(<em>value1</em>[,<em>value2</em>, ...]) </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value1, value2, ...</code></dt> @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/max <p>返回给定的一组数字中的最大值。如果给定的参数中至少有一个参数无法被转换成数字,则会返回 {{jsxref("NaN")}}。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>max</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.max()</code>,而不是创建的 <code>Math</code> 实例的方法(<code>Math</code> 不是构造函数)。</p> @@ -35,9 +35,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/max <p>如果有任一参数不能被转换为数值,则结果为 {{jsxref("NaN")}}。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_Math.max" name="Example:_Using_Math.max">使用 <code>Math.max()</code></h3> +<h3 id="Example_Using_Math.max">使用 <code>Math.max()</code></h3> <pre>Math.max(10, 20); // 20 Math.max(-10, -20); // -10 @@ -92,7 +92,7 @@ var max = Math.max(...arr); <p>{{Compat("javascript.builtins.Math.max")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Math.min()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/min/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/min/index.html index a5a5a6defc..068ffd7bd6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/min/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/min/index.html @@ -13,11 +13,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/min <p><code><strong>Math.min()</strong></code> 返回零个或更多个数值的最小值。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.min([<em>value1</em>[,<em>value2</em>, ...]]) </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value1, value2, ...</code></dt> @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/min <p>给定数值中最小的数。如果任一参数不能转换为数值,则返回{{jsxref("NaN")}}。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>min</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.min()</code>,而不是作为你创建的 <code>Math</code> 实例的方法(Math 不是构造函数)。</p> @@ -36,9 +36,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/min <p>如果有任一参数不能被转换为数值,结果为 {{jsxref("NaN")}}。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Using_Math.min" name="Example:_Using_Math.min">使用 <code>Math.min()</code></h3> +<h3 id="Example:_Using_Math.min">使用 <code>Math.min()</code></h3> <p>下例找出 x 和 y 的最小值,并把它赋值给 z:</p> @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/min var z = Math.min(x, y); </pre> -<h3 id="Example.3A_Clipping_a_value_with_Math.min" name="Example.3A_Clipping_a_value_with_Math.min">使用 <code>Math.min()</code> 裁剪值(Clipping a value)</h3> +<h3 id="Example.3A_Clipping_a_value_with_Math.min">使用 <code>Math.min()</code> 裁剪值(Clipping a value)</h3> <p><code>Math.min</code> 经常用于裁剪一个值,以便使其总是小于或等于某个边界值。例如:</p> @@ -148,7 +148,7 @@ if (x > boundary) { </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Math.max()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html index efc463d5b7..3fc466cb3b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/pi/index.html @@ -5,7 +5,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/PI --- <div>{{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.PI</strong></code> 表示一个圆的周长与直径的比例,约为 3.14159:</p> @@ -13,13 +13,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/PI <div>{{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>PI</code> 是 <code>Math</code> 的静态属性,所以应该像这样使用:<code>Math.PI</code>,而不是作为你创建的 <code>Math</code> 实例的属性(<code>Math</code> 不是构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Using_PI" name="Example:_Using_PI">使用 <code>Math.PI</code></h3> +<h3 id="Example:_Using_PI">使用 <code>Math.PI</code></h3> <p>下面的函数使用 Math.PI 计算给定半径的圆周长:</p> @@ -108,7 +108,7 @@ calculateCircumference(1); // 6.283185307179586</pre> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/pow/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/pow/index.html index 9138f6d635..7e9b8ba09e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/pow/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/pow/index.html @@ -9,11 +9,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/pow <p>{{EmbedInteractiveExample("pages/js/math-pow.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.pow(<em>base</em>, <em>exponent</em>) </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>base</code></dt> @@ -22,13 +22,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/pow <dd>指数</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>pow</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.pow()</code>,而不是作为你创建的 <code>Math</code> 对象的方法。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_Math.pow" name="Example:_Using_Math.pow">使用 <code>Math.pow</code></h3> +<h3 id="Example_Using_Math.pow">使用 <code>Math.pow</code></h3> <pre class="brush:js">function raisePower(x,y) { return Math.pow(x,y) @@ -67,7 +67,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/pow <p>{{Compat("javascript.builtins.Math.pow")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Math.cbrt()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html index 04602b2699..6924bb32c5 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/random/index.html @@ -19,15 +19,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random <p><code>Math.random()</code> <em>不能</em>提供像密码一样安全的随机数字。不要使用它们来处理有关安全的事情。使用Web Crypto API 来代替, 和更精确的{{domxref("RandomSource.getRandomValues()", "window.crypto.getRandomValues()")}} 方法.</p> </div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.random()</code></pre> -<h3 id="Parameters" name="Parameters">返回值</h3> +<h3 id="Parameters">返回值</h3> <p>一个浮点型伪随机数字,在<code>0</code>(包括0)和<code>1</code>(不包括)之间。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <p>请注意, 由于 JavaScript 中的数字是 IEEE 754 浮点数字,具有最近舍入( round-to-nearest-even)的行为, 因此以下函数的范围 (不包括<code>Math.random()</code> 本身) 并不准确。如果选择了非常大的边界 (2<sup>53</sup> 或更高), 在极罕见的情况下会计算通常-排除(usually-excluded)的上界。(注:round-to-nearest-even采用最近舍入的去偶数舍入的方式,对.5的舍入上,采用取偶数的方式)</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/round/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/round/index.html index 409b9dbaa1..8cc263a27d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/round/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/round/index.html @@ -10,11 +10,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/round <p><code><strong>Math.round()</strong></code> 函数返回一个数字四舍五入后最接近的整数。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.round(<em>x</em>) </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> @@ -26,13 +26,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/round </dt> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果参数的小数部分大于 0.5,则舍入到相邻的绝对值更大的整数。 如果参数的小数部分小于 0.5,则舍入到相邻的绝对值更小的整数。如果参数的小数部分恰好等于0.5,则舍入到相邻的在正无穷(+∞)方向上的整数。<strong>注意,与很多其他语言中的<code>round()函数</code>不同,<code>Math.round()并不总是舍入到远离0的方向(尤其是在负数的小数部分恰好等于0.5的情况下)。</code></strong></p> <p>因为 <code>round()</code> 是 <code>Math</code> 的静态方法,你应该直接使用 <code>Math.round()</code>,而不是作为你创建的 <code>Math</code> 对象的一个实例方法来使用(<code>Math</code>没有构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush:js">x = Math.round(20.49); //20 x = Math.round(20.5); //21 @@ -40,7 +40,7 @@ x = Math.round(-20.5); //-20 x = Math.round(-20.51); //-21 </pre> -<h3 id="Example:_Decimal_rounding" name="Example:_Decimal_rounding">小数舍入</h3> +<h3 id="Example:_Decimal_rounding">小数舍入</h3> <pre class="brush: js">// 闭包 (function(){ @@ -203,7 +203,7 @@ round(1.005, 2); //1.01 </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <p></p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html index 590089e3c1..3501c97fd8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/sign/index.html @@ -13,18 +13,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/sign <p><strong><code>Math.sign()</code></strong> 函数返回一个数字的符号, 指示数字是正数,负数还是零。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.sign(<em>x</em>);</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>任意数字.</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>因为 <code>sign </code>是 <code>Math </code>的一个静态方法,所以你应该使用 Math.sign() ,而不是作为你创建的一个Math对象的一种方法 (Math不是一个构造函数)。</p> @@ -34,7 +34,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/sign <p>传入该函数的参数会被<strong>隐式转换</strong>成数字类型。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="使用Math.sign()">使用Math.sign()</h3> @@ -48,7 +48,7 @@ Math.sign("foo"); // NaN Math.sign(); // NaN </pre> -<h2 id="Compatibility" name="Compatibility">Polyfill</h2> +<h2 id="Compatibility">Polyfill</h2> <pre class="brush: js language-js">function sign(x) { x = +x ;// convert to a number @@ -145,7 +145,7 @@ Math.sign(); // NaN </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/Math", "Math")}} 对象</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/sin/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/sin/index.html index fffb0dc1a1..866091c8b8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/sin/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/sin/index.html @@ -5,30 +5,30 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/sin --- <div>{{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.sin()</strong></code> 函数返回一个数值的正弦值。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.sin(<em>x</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>一个数值(以弧度为单位)。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>sin</code> 方法返回一个 -1 到 1 之间的数值,表示给定角度(单位:弧度)的正弦值。</p> <p>由于 <code>sin</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.sin()</code>,而不是作为你创建的 <code>Math</code> 实例的方法。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_Math.sin" name="Example:_Using_Math.sin">例子:使用 <code>Math.sin</code></h3> +<h3 id="Example_Using_Math.sin">例子:使用 <code>Math.sin</code></h3> <pre class="brush:js">Math.sin(0); // 0 Math.sin(1); // 0.8414709848078965 @@ -68,7 +68,7 @@ Math.sin(Math.PI / 2); // 1</pre> <div></div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Math.acos()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/sinh/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/sinh/index.html index 7ba28b5f3d..899783ca75 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/sinh/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/sinh/index.html @@ -5,28 +5,28 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/sinh --- <div>{{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p> <code><strong>Math.sinh()</strong></code> 函数返回一个数字(单位为角度)的双曲正弦值.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.sinh(<em>x</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>任意数字 (单位为度).</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>双曲正弦的图像如下:</p> <p><img alt="" src="http://upload.wikimedia.org/wikipedia/commons/1/17/Sinh.png" style="height: 300px; width: 300px;"></p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush:js">Math.sinh(0) // 0 Math.sinh(1) // 1.1752011936438014 @@ -111,7 +111,7 @@ Math.sinh("foo") // NaN </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Math.acos()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/sqrt/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/sqrt/index.html index badb08802a..320bb70e74 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/sqrt/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/sqrt/index.html @@ -11,26 +11,26 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/sqrt <p>{{EmbedInteractiveExample("pages/js/math-sqrt.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Math.sqrt(<em>x</em>) </code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>x</code></dt> <dd>一个数值</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果参数 <code>number</code> 为负值,则 <code>sqrt</code> 返回{{jsxref("NaN")}}。</p> <p>由于 <code>sqrt</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用:<code>Math.sqrt()</code>,而不是作为你创建的 <code>Math</code> 实例的方法。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_Math.sqrt" name="Example:_Using_Math.sqrt">使用 <code>Math.sqrt</code></h3> +<h3 id="Example_Using_Math.sqrt">使用 <code>Math.sqrt</code></h3> <pre><code>Math.sqrt(9); // 3 Math.sqrt(2); // 1.414213562373095 diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/sqrt1_2/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/sqrt1_2/index.html index 2c3c139abe..413f66b993 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/sqrt1_2/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/sqrt1_2/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2 --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.SQRT1_2</strong></code> 属性表示 1/2 的平方根,约为 0.707:</p> <p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mi>Math.SQRT1_2</mi></mstyle><mo>=</mo><msqrt><mfrac><mn>1</mn><mn>2</mn></mfrac></msqrt><mo>=</mo><mfrac><mn>1</mn><msqrt><mn>2</mn></msqrt></mfrac><mo>≈</mo><mn>0.707</mn></mrow><annotation encoding="TeX">\mathtt{\mi{Math.SQRT1_2}} = \sqrt{\frac{1}{2}} = \frac{1}{\sqrt{2}} \approx 0.707</annotation></semantics></math></p> <div> {{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>SQRT1_2</code> 是 <code>Math</code> 对象的静态属性,所以应该像这样使用:<code>Math.SQRT1_2</code>,而不是作为你创建的 <code>Math</code> 实例的属性(<code>Math</code> 不是构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_SQRT1_2" name="Example:_Using_SQRT1_2">例子:使用 <code>SQRT1_2</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_SQRT1_2">例子:使用 <code>SQRT1_2</code></h3> <p>下面的函数返回 1/2 的平方根:</p> <pre class="brush:js">function getRoot1_2() { return Math.SQRT1_2 @@ -94,7 +94,7 @@ getRoot1_2() // 0.7071067811865476</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/sqrt2/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/sqrt2/index.html index 8eb81b8572..2c299fde7e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/sqrt2/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/sqrt2/index.html @@ -4,12 +4,12 @@ slug: Web/JavaScript/Reference/Global_Objects/Math/SQRT2 translation_of: Web/JavaScript/Reference/Global_Objects/Math/SQRT2 --- <p>{{JSRef("Global_Objects", "Math")}}</p> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.SQRT2</strong></code> 属性表示 2 的平方根,约为 1.414:</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>由于 <code>SQRT2</code> 是 <code>Math</code> 的静态属性,所以应该像这样使用:<code>Math.SQRT2</code>,而不是作为你创建的 <code>Math</code> 实例的属性(<code>Math</code> 不是构造函数)。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.SQRT2" name="Example:_Using_Math.SQRT2">例子:使用 <code>Math.SQRT2</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.SQRT2">例子:使用 <code>Math.SQRT2</code></h3> <p>下面的函数返回 2 的平方根:</p> <pre class="brush:js">function getRoot2() { return Math.SQRT2; @@ -89,7 +89,7 @@ getRoot2(); // 1.4142135623730951</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/tan/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/tan/index.html index 49e0f3c7c2..3ecf39169a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/tan/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/tan/index.html @@ -5,22 +5,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/tan --- <div> {{JSRef("Global_Objects", "Math")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Math.tan()</strong></code> 方法返回一个数值的正切值。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.tan(<em>x</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt> <code>x</code></dt> <dd> 一个数值,表示一个角(单位:弧度)。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>tan</code> 方法返回一个数值,表示一个角的正切值。</p> <p>由于 <code>tan</code> 是 <code>Math</code> 的静态方法,所以应该像这样使用 <code>Math.tan()</code>,而不是作为你创建的 <code>Math</code> 实例的方法。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_Math.tan" name="Example:_Using_Math.tan">例子:使用 <code>Math.tan</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_Math.tan">例子:使用 <code>Math.tan</code></h3> <p>下面的函数返回变量 <code>x</code> 的正切值:</p> <pre class="brush:js">function getTan(x) { return Math.tan(x); diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/trunc/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/trunc/index.html index 485a96e75d..3568f3bd78 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/trunc/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/trunc/index.html @@ -12,11 +12,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/trunc <p><code><strong>Math.trunc()</strong></code> 方法会将数字的小数部分去掉,只保留整数部分。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Math.trunc(<em>value</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value</code></dt> @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/trunc <p>给定数字的整数部分</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>不像 <code>Math</code> 的其他三个方法: {{jsxref("Math.floor()")}}、{{jsxref("Math.ceil()")}}、{{jsxref("Math.round()")}} ,<code>Math.trunc()</code> 的执行逻辑很简单,仅仅是<strong>删除</strong>掉数字的小数部分和小数点,不管参数是正数还是负数。</p> @@ -35,7 +35,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/trunc <p>因为 <code>trunc()</code> 是 <code>Math</code> 对象的静态方法,你必须用 <code>Math.trunc()</code> 来使用,而不是调用你创建的 <code>Math</code> 对象的一个实例方法(<code>Math</code> 没有构造函数)</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush:js">Math.trunc(13.37) // 13 Math.trunc(42.84) // 42 diff --git a/files/zh-cn/web/javascript/reference/global_objects/nan/index.html b/files/zh-cn/web/javascript/reference/global_objects/nan/index.html index 95eda30e2e..51f7154aa5 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/nan/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/nan/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/NaN <div>{{EmbedInteractiveExample("pages/js/globalprops-nan.html")}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>NaN</code> 是一个<em>全局对象</em>的属性。</p> @@ -59,7 +59,7 @@ Number.isNaN('hello world'); // false</code></pre> <p>{{Compat("javascript.builtins.NaN")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Number.NaN")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/index.html index d53c952ea3..d6c608f748 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/index.html @@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number <p>最近出了stage3{{jsxref("BigInt")}} 任意精度数字类型,已经进入stage3规范</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre>new Number(<em>value</em>); var <em>a</em> = new Number('123'); // a === 123 is false @@ -23,14 +23,14 @@ var <em>b</em> = Number('123'); // b === 123 is true <em>a</em> instanceof Number; // is true <em>b</em> instanceof Number; // is false</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value</code></dt> <dd>被创建对象的数字值。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>Number</code> 对象主要用于:</p> @@ -39,7 +39,7 @@ var <em>b</em> = Number('123'); // b === 123 is true <li>在非构造器上下文中 (如:没有 {{jsxref("Operators/new", "new")}} 操作符),<code>Number</code> 能被用来执行类型转换。</li> </ul> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt>{{jsxref("Number.EPSILON")}}</dt> @@ -62,7 +62,7 @@ var <em>b</em> = Number('123'); // b === 123 is true <dd>Number 对象上允许的额外属性。</dd> </dl> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <dl> <dt>{{jsxref("Number.isNaN()")}}</dt> @@ -86,17 +86,17 @@ var <em>b</em> = Number('123'); // b === 123 is true </dl> </div> -<h2 id="Number_instances" name="Number_instances"><code>Number</code> 实例</h2> +<h2 id="Number_instances"><code>Number</code> 实例</h2> <p>所有 <code>Number</code> 实例都继承自 {{jsxref("Number.prototype")}}。<code>被修改的 Number</code> 构造器的原型对象对全部 <code>Number</code> 实例都生效。</p> -<h3 id="Methods_of_number_instance" name="Methods_of_number_instance">方法</h3> +<h3 id="Methods_of_number_instance">方法</h3> <div>{{page('/zh-CN/docs/JavaScript/Reference/Global_Objects/Number/prototype', 'Methods')}}</div> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_the_Number_object_to_assign_values_to_numeric_variables" name="Example:_Using_the_Number_object_to_assign_values_to_numeric_variables">使用 Number 对象给数字变量赋值</h3> +<h3 id="Example_Using_the_Number_object_to_assign_values_to_numeric_variables">使用 Number 对象给数字变量赋值</h3> <p>下例使用 <code>Number</code> 对象的属性给几个数字变量赋值:</p> @@ -118,7 +118,7 @@ var smallestInt = Number.MIN_SAFE_INTEGER; <p>在解析序列化的JSON时,如果JSON解析器将它们强制转换为Number类型,那么超出此范围的整数值可能会被破坏。在工作中使用{{jsxref("String")}} 类型代替,是一个可行的解决方案。</p> -<h3 id="Example_Using_Number_to_convert_a_Date_object" name="Example:_Using_Number_to_convert_a_Date_object">使用 <code>Number</code> 转换 <code>Date</code> 对象</h3> +<h3 id="Example_Using_Number_to_convert_a_Date_object">使用 <code>Number</code> 转换 <code>Date</code> 对象</h3> <p>下例使用 Number 作为函数来转换 <code>Date</code> 对象为数字值:</p> @@ -175,13 +175,13 @@ Number('-Infinity') //-Infinity</pre> </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> <p>{{Compat("javascript.builtins.Number")}}</p> </div> -<h2 id="See_also" name="See_also">参阅</h2> +<h2 id="See_also">参阅</h2> <ul> <li>{{jsxref("NaN")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/isfinite/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/isfinite/index.html index 47a2ee8f0b..f9caca9ba1 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/isfinite/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/isfinite/index.html @@ -15,11 +15,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/isFinite <p>{{EmbedInteractiveExample("pages/js/number-isfinite.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Number.isFinite(v<var>alue</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value</code></dt> @@ -77,11 +77,11 @@ Number.isFinite(null); // false, would've been true with </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div>{{Compat("javascript.builtins.Number.isFinite")}}</div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>The {{jsxref("Number")}} object it belongs to.</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/isinteger/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/isinteger/index.html index 742abe51a6..52c4ead503 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/isinteger/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/isinteger/index.html @@ -15,11 +15,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/isInteger <p>{{EmbedInteractiveExample("pages/js/number-isinteger.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Number.isInteger(v<var>alue</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>value</code></dt> @@ -30,11 +30,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/isInteger <p>判断给定值是否是整数的 {{jsxref("Boolean")}} 值。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果被检测的值是整数,则返回 <code>true</code>,否则返回 <code>false</code>。注意 {{jsxref("Global_Objects/NaN", "NaN")}} 和正负 {{jsxref("Global_Objects/Infinity", "Infinity")}} 不是整数。</p> -<h2 id="Example" name="Example">示例</h2> +<h2 id="Example">示例</h2> <pre class="brush: js">Number.isInteger(0); // true Number.isInteger(1); // true @@ -50,7 +50,7 @@ Number.isInteger(true); // false Number.isInteger(false); // false Number.isInteger([1]); // false</pre> -<h2 id="Polyfill" name="Polyfill">Polyfill</h2> +<h2 id="Polyfill">Polyfill</h2> <pre class="brush: js">Number.isInteger = Number.isInteger || function(value) { return typeof value === "number" && @@ -81,11 +81,11 @@ Number.isInteger([1]); // false</pre> </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <p>{{Compat("javascript.builtins.Number.isInteger")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/Number", "Number")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/issafeinteger/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/issafeinteger/index.html index e0755f390a..d2993e499e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/issafeinteger/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/issafeinteger/index.html @@ -18,11 +18,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger <p>安全整数范围为 <code>-(2<sup>53</sup> - 1)到</code> <code>2<sup>53</sup> - 1 </code>之间的整数,包含 <code>-(2<sup>53</sup> - 1)和</code> <code>2<sup>53</sup> - 1</code>。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Number.isSafeInteger(<var>testValue</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code><var>testValue</var></code></dt> @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger <p>一个{{jsxref("Boolean", "布尔值")}} 表示给定的值是否是一个安全整数(safe integer)。</p> -<h2 id="Example" name="Example">示例</h2> +<h2 id="Example">示例</h2> <pre class="brush:js">Number.isSafeInteger(3); // true Number.isSafeInteger(Math.pow(2, 53)) // false @@ -73,7 +73,7 @@ Number.isSafeInteger(3.0); // true </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <p>{{Compat("javascript.builtins.Number.isSafeInteger")}}</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/max_value/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/max_value/index.html index 30e25ab13c..db8250d873 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/max_value/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/max_value/index.html @@ -5,21 +5,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE --- <div>{{JSRef("Global_Objects", "Number")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Number.MAX_VALUE</strong></code> 属性表示在 JavaScript 里所能表示的最大数值。</p> <p>{{js_property_attributes(0,0,0)}}</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>MAX_VALUE</code> 属性值接近于 <code>1.79E+308</code>。大于 <code>MAX_VALUE</code> 的值代表 "<code>Infinity</code>"。</p> <p>因为 <code>MAX_VALUE</code> 是 <code>Number</code> 对象的一个静态属性,所以你应该直接使用<code>Number.MAX_VALUE</code> ,而不是作为一个创建的 <code>Number</code> 实例的属性。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Using_MAX_VALUE" name="Example:_Using_MAX_VALUE">例子:使用 <code>MAX_VALUE</code></h3> +<h3 id="Example:_Using_MAX_VALUE">例子:使用 <code>MAX_VALUE</code></h3> <p>下面的代码求两个数值的乘积。如果结果小于等于 <code>MAX_VALUE</code>,则调用 <code>func1</code> 函数;否则,调用 <code>func2</code> 函数。</p> @@ -108,7 +108,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Number.MIN_VALUE")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/min_value/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/min_value/index.html index b61649b58b..ba746ab29c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/min_value/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/min_value/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE --- <div> {{JSRef("Global_Objects", "Number")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Number.MIN_VALUE</strong></code> 属性表示在 JavaScript 中所能表示的最小的正值。</p> <p>{{js_property_attributes(0,0,0)}}</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>MIN_VALUE</code> 属性是 JavaScript 里最接近 0 的正值,而不是最小的负值。</p> <p><code>MIN_VALUE</code> 的值约为 5e-324。小于 <code>MIN_VALUE</code> ("underflow values") 的值将会转换为 0。</p> <p>因为 <code>MIN_VALUE</code> 是 <code>Number</code> 的一个静态属性,因此应该直接使用: <code>Number.MIN_VALUE,</code> 而不是作为一个创建的 <code>Number</code> 实例的属性。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_MIN_VALUE" name="Example:_Using_MIN_VALUE">例子:使用 <code>MIN_VALUE</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_MIN_VALUE">例子:使用 <code>MIN_VALUE</code></h3> <p>下面的代码里两个数值相除。如果结果大于或等于 <code>MIN_VALUE</code>,则调用 <code>func1</code> 函数;否则,调用 <code>func2</code> 函数。</p> <pre class="brush:js">if (num1 / num2 >= Number.MIN_VALUE) { func1(); @@ -93,7 +93,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Number.MAX_VALUE")}}</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/nan/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/nan/index.html index e7df054c6f..03f0bf5fb0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/nan/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/nan/index.html @@ -5,7 +5,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/NaN --- <div>{{JSRef("Global_Objects", "Number")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Number.NaN</strong></code> 表示“非数字”(Not-A-Number)。和 {{jsxref("Global_Objects/NaN", "NaN")}} 相同。</p> @@ -97,7 +97,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/NaN </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>全局对象 {{jsxref("Global_Objects/NaN", "NaN")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity/index.html index 1078f84668..62112cb949 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/negative_infinity/index.html @@ -5,11 +5,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY --- <div> {{JSRef("Global_Objects", "Number")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Number.NEGATIVE_INFINITY</strong></code> 属性表示负无穷大。</p> <p>不用创建一个 {{jsxref("Global_Objects/Number", "Number")}} 实例,使用 <code>Number.NEGATIVE_INFINITY</code> 来访问该静态属性。</p> <p>{{js_property_attributes(0,0,0)}}</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>Number.NEGATIVE_INFINITY</code> 的值和全局对象的 {{jsxref("Global_Objects/Infinity", "Infinity")}} 属性的负值相同。</p> <p>该值的行为同数学上的无穷大(infinity)有一点儿不同:</p> <ul> @@ -23,7 +23,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY <li>任何数除以 <code>NEGATIVE_INFINITY</code> 为 0。</li> </ul> <p>为了成功返回一个有限值,你可能会使用 <code>Number.NEGATIVE_INFINITY</code> 属性来判断是否显示一个条件错误 。然而 {{jsxref("Global_Objects/isFinite", "isFinite")}} 方法更适合这种情况。</p> -<h2 id="Example" name="Example">示例</h2> +<h2 id="Example">示例</h2> <p>下例中,赋值给变量 <code>smallNumber</code> 一个明显小于 JavaScript 中的最小值的值。当 <code>if</code> 语句执行时,<code>smallNumber</code> 值为 "<code>-Infinity</code>",因此在继续执行代码前,<code>smallNumber</code> 被设为一个更容易管理的值。</p> <pre class="brush:js">var smallNumber = (-Number.MAX_VALUE) * 2 @@ -104,7 +104,7 @@ if (smallNumber == Number.NEGATIVE_INFINITY) { </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Number.POSITIVE_INFINITY")}}</li> <li>{{jsxref("Global_Objects/Infinity", "Infinity")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/parsefloat/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/parsefloat/index.html index 85926e5d09..705c63b712 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/parsefloat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/parsefloat/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseFloat --- <div>{{JSRef("Global_Objects", "Number")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><strong><code>Number.parseFloat()</code></strong> 方法可以把一个字符串解析成浮点数。该方法与全局的 {{jsxref("Global_Objects/parseFloat", "parseFloat()")}} 函数相同,并且处于 ECMAScript 6 规范中(用于全局变量的模块化)。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Number.parseFloat(<var>string</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>string</code></dt> @@ -49,7 +49,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseFloat </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div>{{CompatibilityTable}}</div> @@ -101,7 +101,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseFloat </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/Number", "Number")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/parseint/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/parseint/index.html index 56f1d834be..e1b466489f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/parseint/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/parseint/index.html @@ -10,11 +10,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseInt --- <div>{{JSRef}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><strong><code>Number.parseInt()</code></strong> 方法依据指定基数 [ 参数 <strong>radix </strong>的值],把字符串 [ 参数 <strong>string</strong> 的值] 解析成整数。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Number.parseInt(<var>string</var>[, <var>radix</var>])</code> </pre> @@ -74,7 +74,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseInt <p>{{Compat("javascript.builtins.Number.parseInt")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><code>{{jsxref("Global_Objects/Number", "Number()")}}</code></li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/positive_infinity/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/positive_infinity/index.html index e9020ba078..e2b77c5d51 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/positive_infinity/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/positive_infinity/index.html @@ -121,7 +121,7 @@ if (bigNumber == Number.POSITIVE_INFINITY) { </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Number.NEGATIVE_INFINITY")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/toexponential/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/toexponential/index.html index 97ed9f8a6d..1847290f1a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/toexponential/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/toexponential/index.html @@ -5,22 +5,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toExponential --- <div>{{JSRef("Global_Objects", "Number")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><strong><code>toExponential()</code></strong> 方法以指数表示法返回该数值字符串表示形式。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>numObj</em>.toExponential(<em>fractionDigits</em>)</code></pre> -<h3 id="Parameter" name="Parameter">参数</h3> +<h3 id="Parameter">参数</h3> <dl> <dt>fractionDigits</dt> <dd>可选。一个整数,用来指定小数点后有几位数字。默认情况下用尽可能多的位数来显示数字。</dd> </dl> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p>一个用幂的形式 (科学记数法) 来表示{{jsxref("Number")}} 对象的字符串。小数点后以fractionDigits 提供的值来四舍五入。如果 <code>fractionDigits</code> 参数被忽略了,小数点后的将尽可能用最多的位数来表示该数值。</p> @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toExponential <p>如果一个数值的小数位数多余 <code>fractionDigits</code> 参数所提供的,则该数值将会在 <code>fractionDigits</code> 指定的小数位数处四舍五入。可以查看 {{jsxref("Number.toFixed", "toFixed()")}} 方法描述中关于四舍五入的讨论,同样应用于 <code>toExponential() </code>方法。</p> -<h3 id="Throws" name="Throws">异常</h3> +<h3 id="Throws">异常</h3> <dl> <dt>{{jsxref("Global_Objects/RangeError", "RangeError")}}</dt> @@ -40,7 +40,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toExponential <dd>如果该方法在一个非数值类型对象上调用。</dd> </dl> -<h2 id="Example" name="Example">示例</h2> +<h2 id="Example">示例</h2> <pre class="brush:js">var numObj = 77.1234; @@ -133,7 +133,7 @@ alert("77 .toExponential() is " + 77 .toExponential()); //输出 7.7e+1</pre> </table> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Number.prototype.toFixed()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/tofixed/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/tofixed/index.html index fcf55b0517..95787ab74f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/tofixed/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/tofixed/index.html @@ -9,22 +9,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toFixed <div>{{EmbedInteractiveExample("pages/js/number-tofixed.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>numObj</em>.toFixed(<em>digits</em>)</code></pre> -<h3 id="Parameter" name="Parameter">参数</h3> +<h3 id="Parameter">参数</h3> <dl> <dt>digits</dt> <dd>小数点后数字的个数;介于 0 到 20 (包括)之间,实现环境可能支持更大范围。如果忽略该参数,则默认为 0。</dd> </dl> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p>使用定点表示法表示给定数字的字符串。</p> -<h3 id="Throws" name="Throws">抛出异常</h3> +<h3 id="Throws">抛出异常</h3> <dl> <dt>{{jsxref("RangeError")}}</dt> @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toFixed <p><strong>Warning:</strong> 浮点数不能精确地用二进制表示所有小数。这可能会导致意外的结果,例如 <code>0.1 + 0.2 === 0.3</code> 返回 <code>false</code> .</p> </div> -<h2 id="Example" name="Example">示例</h2> +<h2 id="Example">示例</h2> <h3 id="使用_toFixed">使用 <code>toFixed</code></h3> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/toprecision/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/toprecision/index.html index ec964370f1..ff4e3425c3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/toprecision/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/toprecision/index.html @@ -5,22 +5,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toPrecision --- <div>{{JSRef("Global_Objects", "Number")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>toPrecision()</strong></code> 方法以指定的精度返回该数值对象的字符串表示。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>numObj</em>.toPrecision(<em>precision</em>)</code></pre> -<h3 id="Parameter" name="Parameter">参数</h3> +<h3 id="Parameter">参数</h3> <dl> <dt>precision</dt> <dd>可选。一个用来指定有效数个数的整数。</dd> </dl> -<h3 id="Returns" name="Returns">返回值</h3> +<h3 id="Returns">返回值</h3> <p>以定点表示法或指数表示法表示的一个数值对象的字符串表示,四舍五入到 <code>precision</code> 参数指定的显示数字位数。查看 {{jsxref("Number.prototype.toFixed()")}} 方法关于四舍五入的讨论,同样应用于 <code>toPrecision</code> 方法。</p> @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toPrecision <dd>如果 <em>precison</em> 参数不在 1 和 100 (包括)之间,将会抛出一个 <code>RangeError</code> 。执行环境也可以支持更大或更小的范围。ECMA-262 只需要最多 21 位显示数字。</dd> </dl> -<h2 id="Example" name="Example">示例</h2> +<h2 id="Example">示例</h2> <pre class="brush: js">var numObj = 5.123456; console.log("numObj.toPrecision() is " + numObj.toPrecision()); //输出 5.123456 @@ -124,7 +124,7 @@ console.log((1234.5).toPrecision(2)); // "1.2e+3" </table> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Number.prototype.toFixed()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/tosource/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/tosource/index.html index 9355dbb11d..ad95155237 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/tosource/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/tosource/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toSource --- <div> {{JSRef("Global_Objects", "Number")}} {{ Non-standard_header() }}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>toSource()</strong></code> 方法返回该对象源码的字符串表示。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">numObj.toSource(); Number.toSource(); </pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>toSource()</code> 方法返回下列值:</p> <ul> @@ -74,7 +74,7 @@ Number.toSource(); </tbody> </table> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.toSource()")}}</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/tostring/index.html index 2a7407aa25..7c438cb6f7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/tostring/index.html @@ -11,12 +11,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toString <p><strong><code>toString()</code></strong> 方法返回指定 {{jsxref("Number")}} 对象的字符串表示形式。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre><code><var>numObj</var>.toString([<var>radix</var>])</code> </pre> -<h3 id="Parameter" name="Parameter">参数</h3> +<h3 id="Parameter">参数</h3> <dl> <dt>radix</dt> @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toString </dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Number")}} 对象覆盖了 {{jsxref("Object")}} 对象上的 <code>toString()</code> 方法,它不是继承的 {{jsxref("Object.prototype.toString()")}}。对于 {{jsxref( "Number")}} 对象,<code>toString()</code> 方法以指定的基数返回该对象的字符串表示。</p> @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toString <p>进行数字到字符串的转换时,建议<strong>用小括号将要转换的目标括起来</strong>,防止出错。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <pre class="brush: js"><code>var count = 10; diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/valueof/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/valueof/index.html index 1b56f29115..dc97f672f8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/valueof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/valueof/index.html @@ -10,23 +10,23 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/valueOf --- <div>{{JSRef("Global_Objects", "Number")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><strong><code>valueOf()</code></strong> 方法返回一个被 {{jsxref("Global_Objects/Number", "Number")}} 对象包装的原始值。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>numObj</var>.valueOf()</code></pre> -<h3 id="Parameters" name="Parameters">返回值</h3> +<h3 id="Parameters">返回值</h3> <p>表示指定 {{jsxref("Number")}} 对象的原始值的数字</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>该方法通常是由 JavaScript 引擎在内部隐式调用的,而不是由用户在代码中显式调用的。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">var numObj = new Number(10); console.log(typeof numObj); // object @@ -115,7 +115,7 @@ console.log(typeof num); // number </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Number.prototype.toSource()")}}</li> 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 209a7897e3..b0229c493e 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 @@ -5,11 +5,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__ --- <div> {{JSRef("Global_Objects", "Object")}} {{non-standard_header}} {{deprecated_header}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>__defineGetter__</strong></code> 方法可以将一个函数绑定在当前对象的指定属性上,当那个属性的值被读取时,你所绑定的函数就会被调用。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>obj</var>.__defineGetter__(<var>prop</var>, <var>func</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt> <code>prop</code></dt> @@ -20,9 +20,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__ <dd> 一个函数,当 <code>prop</code> 属性的值被读取时自动被调用。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>__defineGetter__ 方法可以为一个已经存在的对象设置(新建或修改)访问器属性,</code>而 {{jsxref("Operators/get", "对象字面量中的 get 语法", "", 1)}} 只能在新建一个对象时使用。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">// 请注意,该方法是非标准的: var o = {}; @@ -45,9 +45,9 @@ Object.defineProperty(o, 'gimmeFive', { }); console.log(o.gimmeFive); // 5 </pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <p>不属于任何规范。</p> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> {{CompatibilityTable}}</div> <div> @@ -96,7 +96,7 @@ console.log(o.gimmeFive); // 5 </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.__defineSetter__()")}}</li> <li>{{jsxref("Operators/get", "get")}} operator</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 2aaac6314d..b854a96ea0 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 @@ -5,11 +5,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__ --- <div> {{JSRef("Global_Objects", "Object")}} {{non-standard_header}} {{deprecated_header}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>__defineSetter__ </strong>方法可以将一个函数绑定在当前对象的指定属性</code>上,当那个属性被赋值时,你所绑定的函数就会被调用。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>obj</var>.__defineSetter__(<var>prop</var>, <var>fun</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt> <code>prop</code></dt> @@ -28,11 +28,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__ </dl> </dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>__defineSetter__</code> 方法可以为一个已经存在的对象设置(新建或修改)访问器属性,而 {{jsxref("Operators/set", "对象字面量中的 set 语法", "", 1)}} 只能在新建一个对象时使用。</p> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <p>不属于任何规范。</p> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> {{CompatibilityTable}}</div> <div> @@ -81,7 +81,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__ </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.__defineGetter__()")}}</li> <li>{{jsxref("Operators/set", "set")}} operator</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 c9200b5194..52fe502257 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 @@ -5,22 +5,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__ --- <div>{{JSRef("Global_Objects", "Object")}} {{ Non-standard_header }} {{ Deprecated_header }}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>__lookupGetter__</strong></code> 方法会返回当前对象上指定属性的<strong>属性读取访问器函数(getter)。</strong></p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>obj</em>.__lookupGetter__(<em>sprop</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>sprop</code></dt> <dd>属性名</dd> </dl> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">var obj = { get foo() { @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__lookupGetter__ obj.__lookupGetter__("foo") // (function (){return Math.random() > 0.5 ? "foo" : "bar"}) </pre> -<h2 id="Description" name="Description">附注</h2> +<h2 id="Description">附注</h2> <p><code><strong>__lookupGetter__</strong></code> 方法是非标准的,我们应该使用标准中定义的方法来完成同样的事情,那就是 {{jsxref("Object.getOwnPropertyDescriptor()")}} 方法:</p> @@ -53,7 +53,7 @@ Object.getOwnPropertyDescriptor(prototype, "foo").get // function __proto__() {[native code]} </pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <p>不属于任何规范。</p> @@ -109,7 +109,7 @@ Object.getOwnPropertyDescriptor(prototype, "foo").get </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.__lookupSetter__", "Object.prototype.__lookupSetter__()")}}</li> 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 080c859773..c81cacda30 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 @@ -18,11 +18,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Object.assign(<var>target</var>, ...<var>sources</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>target</code></dt> @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign <dd>源对象。</dd> </dl> -<h3 id="Return_value" name="Return_value">返回值</h3> +<h3 id="Return_value">返回值</h3> <p>目标对象。</p> @@ -83,16 +83,16 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign }); }</pre> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Cloning_an_object" name="Example:_Cloning_an_object">复制一个对象</h3> +<h3 id="Example_Cloning_an_object">复制一个对象</h3> <pre class="brush: js">const obj = { a: 1 }; const copy = Object.assign({}, obj); console.log(copy); // { a: 1 } </pre> -<h3 id="Deep_Clone" name="Deep_Clone">深拷贝问题</h3> +<h3 id="Deep_Clone">深拷贝问题</h3> <p>针对深拷贝,需要使用其他办法,因为 <code>Object.assign()</code>拷贝的是(可枚举)属性值。</p> @@ -137,7 +137,7 @@ function test() { test(); </pre> -<h3 id="Example_Merging_objects" name="Example:_Merging_objects">合并对象</h3> +<h3 id="Example_Merging_objects">合并对象</h3> <pre class="brush: js">const o1 = { a: 1 }; const o2 = { b: 2 }; @@ -159,7 +159,7 @@ console.log(obj); // { a: 1, b: 2, c: 3 }</pre> <p>属性被后续参数中具有相同属性的其他对象覆盖。</p> -<h3 id="Example_Symbol_properties" name="Example:_Symbol_properties">拷贝 symbol 类型的属性</h3> +<h3 id="Example_Symbol_properties">拷贝 symbol 类型的属性</h3> <pre class="brush: js">const o1 = { a: 1 }; const o2 = { [Symbol('foo')]: 2 }; @@ -168,7 +168,7 @@ const obj = Object.assign({}, o1, o2); console.log(obj); // { a : 1, [Symbol("foo")]: 2 } (cf. bug 1207182 on Firefox) Object.getOwnPropertySymbols(obj); // [Symbol(foo)]</pre> -<h3 id="Example_Only_own_enumerable_properties" name="Example:_Only_own_enumerable_properties">继承属性和不可枚举属性是不能拷贝的</h3> +<h3 id="Example_Only_own_enumerable_properties">继承属性和不可枚举属性是不能拷贝的</h3> <pre class="brush: js">const obj = Object.create({foo: 1}, { // foo 是个继承属性。 bar: { @@ -184,7 +184,7 @@ const copy = Object.assign({}, obj); console.log(copy); // { baz: 3 } </pre> -<h3 id="Example_Primitives" name="Example:_Primitives">原始类型会被包装为对象</h3> +<h3 id="Example_Primitives">原始类型会被包装为对象</h3> <pre class="brush: js">const v1 = "abc"; const v2 = true; @@ -196,7 +196,7 @@ const obj = Object.assign({}, v1, null, v2, undefined, v3, v4); // 注意,只有字符串的包装对象才可能有自身可枚举属性。 console.log(obj); // { "0": "a", "1": "b", "2": "c" }</pre> -<h3 id="Example_Exceptions" name="Example:_Exceptions">异常会打断后续拷贝任务</h3> +<h3 id="Example_Exceptions">异常会打断后续拷贝任务</h3> <pre class="brush: js">const target = Object.defineProperty({}, "foo", { value: 1, @@ -214,7 +214,7 @@ console.log(target.foo3); // undefined,异常之后 assign 方法就退出了 console.log(target.baz); // undefined,第三个源对象更是不会被拷贝到的。 </pre> -<h3 id="Example_Copy_accessors" name="Example:_Copy_accessors">拷贝访问器</h3> +<h3 id="Example_Copy_accessors">拷贝访问器</h3> <pre class="brush: js">const obj = { foo: 1, @@ -251,7 +251,7 @@ console.log(copy); // { foo:1, get bar() { return 2 } } </pre> -<h2 id="Polyfill" name="Polyfill">Polyfill</h2> +<h2 id="Polyfill">Polyfill</h2> <p>此{{Glossary("Polyfill","polyfill")}}不支持 symbol 属性,因为ES5 中根本没有 symbol :</p> @@ -285,7 +285,7 @@ console.log(copy); }); }</pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -307,11 +307,11 @@ console.log(copy); </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容</h2> +<h2 id="Browser_compatibility">浏览器兼容</h2> <p>{{Compat("javascript.builtins.Object.assign")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.defineProperties()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/constructor/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/constructor/index.html index ac1375763a..8a69de0bb1 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/constructor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/constructor/index.html @@ -12,7 +12,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/constructor <p>返回创建实例对象的 {{jsxref("Object")}} 构造函数的引用。注意,此属性的值是对函数本身的引用,而不是一个包含函数名称的字符串。对原始类型来说,如<code>1</code>,<code>true</code>和<code>"test"</code>,该值只可读。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>所有对象都会从它的原型上继承一个 <code>constructor</code> 属性:</p> @@ -31,9 +31,9 @@ a.constructor === Array // true var n = new Number(3); n.constructor === Number; // true</pre> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Displaying_the_constructor_of_an_object" name="Example:_Displaying_the_constructor_of_an_object">打印一个对象的构造函数</h3> +<h3 id="Example_Displaying_the_constructor_of_an_object">打印一个对象的构造函数</h3> <p>以下示例创建一个原型,<code>Tree</code>,以及该类型的对象,即<code>theTree</code>。 然后打印<code>theTree</code>对象的<code>constructor</code>属性。</p> @@ -50,7 +50,7 @@ console.log( "theTree.constructor is " + theTree.constructor );</pre> this.name = name; }</pre> -<h3 id="Example_Changing_the_constructor_of_an_object" name="Example:_Changing_the_constructor_of_an_object">改变对象的 constructor</h3> +<h3 id="Example_Changing_the_constructor_of_an_object">改变对象的 constructor</h3> <p>下面的例子展示了如何修改基本类型对象的 <code>constructor</code> 属性的值。只有 <code>true</code>, <code>1</code> 和 <code>"test"</code> 的不受影响,因为创建他们的是只读的原生构造函数(native constructors)。这个例子也说明了依赖一个对象的 <code>constructor</code> 属性并不安全。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html index 9bd6e7589c..244698d026 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html @@ -16,11 +16,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/create <div>{{EmbedInteractiveExample("pages/js/object-create.html", "taller")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre>Object.create(<var>proto,[</var><var>propertiesObject</var>])</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>proto</code></dt> @@ -29,15 +29,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/create <dd>可选。需要传入一个对象,该对象的属性类型参照{{jsxref("Object.defineProperties()")}}的第二个参数。如果该参数被指定且不为 {{jsxref("undefined")}},该传入对象的自有可枚举属性(即其自身定义的属性,而不是其原型链上的枚举属性)将为新创建的对象添加指定的属性值和对应的属性描述符。</dd> </dl> -<h3 id="Parameters" name="Parameters">返回值</h3> +<h3 id="Parameters">返回值</h3> <p>一个新对象,带着指定的原型对象和属性。</p> -<h3 id="Description" name="Description">例外</h3> +<h3 id="Description">例外</h3> <p>如果<code>proto</code>参数不是 {{jsxref("null")}} 或非原始包装对象,则抛出一个 {{jsxref("TypeError")}} 异常。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <h3 id="用_Object.create实现类式继承">用 <code>Object.create</code>实现类式继承</h3> @@ -213,7 +213,7 @@ o2 = Object.create({}, { <p>{{Compat("javascript.builtins.Object.create")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.defineProperty")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperties/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperties/index.html index 9758d0af9b..81b3e2fe8b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperties/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperties/index.html @@ -12,11 +12,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperties <p><strong><code>Object.defineProperties()</code> </strong>方法直接在一个对象上定义新的属性或修改现有属性,并返回该对象。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre><code>Object.defineProperties(<var>obj</var>, <var>props</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>obj</code></dt> @@ -172,7 +172,7 @@ Object.defineProperties(obj, { <p>{{Compat("javascript.builtins.Object.defineProperties")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.defineProperty()")}}</li> 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 bd48ad319b..6237badeea 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 @@ -16,11 +16,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/freeze -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Object.freeze(<em>obj</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>obj</code></dt> @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/freeze <p>被冻结的对象。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>被冻结对象自身的所有属性都不可能以任何方式被修改。任何修改尝试都会失败,无论是静默地还是通过抛出{{jsxref("TypeError")}}异常(最常见但不仅限于{{jsxref("Strict_mode", "strict mode", "", 1)}})。</p> @@ -39,7 +39,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/freeze <p>这个方法返回传递的对象,而不是创建一个被冻结的副本。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <h3 id="冻结对象">冻结对象</h3> @@ -193,7 +193,7 @@ TypeError: 1 is not an object // ES5 code <p>{{Compat("javascript.builtins.Object.freeze")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.isFrozen")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.html index b8432c64bd..c9854cdd57 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.html @@ -14,11 +14,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes <p>{{EmbedInteractiveExample("pages/js/object-getownpropertydescriptor.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Object.getOwnPropertyDescriptor(<em>obj</em>, <em>prop</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>obj</code></dt> @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes <p>如果指定的属性存在于对象上,则返回其属性描述符对象(property descriptor),否则返回 {{jsxref("undefined")}}。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>该方法允许对一个属性的描述进行检索。在 Javascript 中, <dfn>属性</dfn> 由一个字符串类型的“名字”(name)和一个“属性描述符”(property descriptor)对象构成。更多关于属性描述符类型以及他们属性的信息可以查看:{{jsxref("Object.defineProperty")}}.</p> @@ -52,7 +52,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes <dd>当且仅当指定对象的属性可以被枚举出时,为 <code>true</code>。</dd> </dl> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">var o, d; diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertynames/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertynames/index.html index 3f86e43049..283fb1e9bd 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertynames/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertynames/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNam <p><strong><code>Object.getOwnPropertyNames()</code></strong>方法返回一个由指定对象的所有自身属性的属性名(包括不可枚举属性但不包括Symbol值作为名称的属性)组成的数组。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox">Object.getOwnPropertyNames(<em>obj</em>)</pre> @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNam <p>在给定对象上找到的自身属性对应的字符串数组。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>Object.getOwnPropertyNames()</code> 返回一个数组,该数组对元素是 <code>obj</code>自身拥有的枚举或不可枚举属性名称字符串。 数组中枚举属性的顺序与通过 {{jsxref("Statements/for...in", "for...in")}} 循环(或 {{jsxref("Object.keys")}})迭代该对象属性时一致。数组中不可枚举属性的顺序未定义。</p> @@ -109,7 +109,7 @@ console.log(nonenum_only);</pre> <pre>注:<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/filter">Array.filter(filt_func)方法</a>创建一个新数组, 其包含通过所提供函数实现的测试的所有元素。</pre> -<h2 id="Notes" name="Notes">提示</h2> +<h2 id="Notes">提示</h2> <p>在 ES5 中,如果参数不是一个原始对象类型,将抛出一个 {{jsxref("TypeError")}} 异常。在 ES2015 中,非对象参数被强制转换为对象 <strong>。</strong></p> @@ -155,7 +155,7 @@ Object.getOwnPropertyNames('foo'); <p>Firefox 28 {{geckoRelease("28")}}之前,<code>Object.getOwnPropertyNames</code> 不会获取到 {{jsxref("Error")}} 对象的属性。该 bug 在后面的版本修复了 ({{bug("724768")}})。</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><a href="https://developer.mozilla.org/en-US/docs/Enumerability_and_ownership_of_properties" title="Enumerability_and_ownership_of_properties">Enumerability and ownership of properties</a></li> 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 228674372c..f763ec6856 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 @@ -12,11 +12,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySym <p><code><strong>Object.getOwnPropertySymbols()</strong></code> 方法返回一个给定对象自身的所有 Symbol 属性的数组。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Object.getOwnPropertySymbols(<em>obj</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>obj</code></dt> @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySym <dd>在给定对象自身上找到的所有 Symbol 属性的数组。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<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 2d8e4928f8..d644eb2f6c 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 @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf <p>{{EmbedInteractiveExample("pages/js/object-getprototypeof.html")}}</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">var proto = {}; var obj = Object.create(proto); @@ -65,7 +65,7 @@ Object.prototype === Object.getPrototypeOf( obj ); // true Object.prototype === Object.getPrototypeOf( {} ); // true</pre> -<h2 id="Notes" name="Notes">Notes</h2> +<h2 id="Notes">Notes</h2> <p>在 ES5 中,如果参数不是一个对象类型,将抛出一个{{jsxref("TypeError")}}异常。在 ES2015 中,参数会被强制转换为一个 {{jsxref("Object")}}<strong>。</strong></p> @@ -109,7 +109,7 @@ Object.getPrototypeOf('foo'); <p>即使旧版本Opera不支持<code>Object.getPrototypeOf()</code>,Opera 10.50之后还支持非标准的 {{jsxref("Object.proto", "__proto__")}}属性。</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.isPrototypeOf")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/index.html index e143a7d49d..69831fc8a8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/index.html @@ -133,9 +133,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example.3A_Using_Object_given_undefined_and_null_types" name="Example.3A_Using_Object_given_undefined_and_null_types">给定 <code>undefined</code> 和 <code>null</code> 类型使用 <code>Object</code></h3> +<h3 id="Example.3A_Using_Object_given_undefined_and_null_types">给定 <code>undefined</code> 和 <code>null</code> 类型使用 <code>Object</code></h3> <p>下面的例子将一个空的 <code>Object</code> 对象存到 <code>o</code> 中:</p> @@ -301,7 +301,7 @@ Object.prototype.valueOf = function() { <p>{{Compat("javascript.builtins.Object")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><a href="/zh-CN/docs/Web/JavaScript/Reference/Operators/Object_initializer">初始化对象</a></li> 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 817dd1296a..1a515b96ff 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 @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isExtensible --- <div>{{JSRef("Global_Objects", "Object")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Object.isExtensible()</strong></code> 方法判断一个对象是否是可扩展的(是否可以在它上面添加新的属性)。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Object.isExtensible(<em>obj</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt>obj</dt> @@ -24,11 +24,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isExtensible <p> 表示给定对象是否可扩展的一个<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Boolean" title="此页面仍未被本地化, 期待您的翻译!"><code>Boolean</code></a> 。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>默认情况下,对象是可扩展的:即可以为他们添加新的属性。以及它们的 {{jsxref("Object.proto", "__proto__")}}{{deprecated_inline}} 属性可以被更改。{{jsxref("Object.preventExtensions")}},{{jsxref("Object.seal")}} 或 {{jsxref("Object.freeze")}} 方法都可以标记一个对象为不可扩展(non-extensible)。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <pre class="brush: js">// 新对象默认是可扩展的. var empty = {}; @@ -133,7 +133,7 @@ Object.isExtensible(1); </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><strong>{{jsxref("Object.preventExtensions")}}</strong></li> 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 9a730a6d2c..cc428900b0 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 @@ -13,11 +13,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isFrozen <p><code><strong>Object.isFrozen()</strong></code>方法判断一个对象是否被{{jsxref("Object.freeze()", "冻结", "", 1)}}。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Object.isFrozen(<var>obj</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>obj</code></dt> @@ -28,11 +28,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isFrozen <dd>表示给定对象是否被冻结的{{jsxref("Boolean")}}。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>一个对象是冻结的是指它不可{{jsxref("Object.isExtensible", "扩展")}},所有属性都是不可配置的,且所有数据属性(即没有getter或setter组件的访问器的属性)都是不可写的。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <pre class="brush: js">// 一个对象默认是可扩展的,所以它也是非冻结的. Object.isFrozen({}); // === false @@ -140,7 +140,7 @@ Object.isFrozen(1); <p>{{Compat("javascript.builtins.Object.isFrozen")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.freeze()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/issealed/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/issealed/index.html index 2a70e41e8e..1bb6ae71d7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/issealed/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/issealed/index.html @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isSealed <p>如果这个对象是密封的,则返回 <code>true</code>,否则返回 <code>false</code>。密封对象是指那些不可 {{jsxref("Object.isExtensible", "扩展")}} 的,且所有自身属性都不可配置且因此不可删除(但不一定是不可写)的对象。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <pre class="brush: js">// 新建的对象默认不是密封的. var empty = {}; diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/keys/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/keys/index.html index 3a778356b0..9509e7e18c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/keys/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/keys/index.html @@ -13,11 +13,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/keys <p><code><strong>Object.keys()</strong></code> 方法会返回一个由一个给定对象的自身可枚举属性组成的数组,数组中属性名的排列顺序和正常循环遍历该对象时返回的顺序一致 。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Object.keys(<var>obj</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt>obj</dt> @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/keys <p>一个表示给定对象的所有可枚举属性的字符串数组。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>Object.keys</code> 返回一个所有元素为字符串的数组,其元素来自于从给定的<code>object</code>上面可直接枚举的属性。这些属性的顺序与手动遍历该对象属性时的一致。</p> @@ -146,7 +146,7 @@ Object.keys("foo"); <p>{{Compat("javascript.builtins.Object.keys")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><a href="https://developer.mozilla.org/en-US/docs/Enumerability_and_ownership_of_properties">Enumerability and ownership of properties</a></li> 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 f412762462..09c0ff1c1a 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 @@ -14,11 +14,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/preventExtensions <p>{{EmbedInteractiveExample("pages/js/object-preventextensions.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Object.preventExtensions(<em>obj</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>obj</code></dt> @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/preventExtensions <dd>已经不可扩展的对象。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果一个对象可以添加新的属性,则这个对象是可扩展的。<code>Object.preventExtensions()</code>将对象标记为不再可扩展,这样它将永远不会具有它被标记为不可扩展时持有的属性之外的属性。注意,一般来说,不可扩展对象的属性可能仍然可被<em>删除</em>。尝试将新属性添加到不可扩展对象将静默失败或抛出{{jsxref("TypeError")}}(最常见的情况是{{jsxref("Functions_and_function_scope/Strict_mode", "strict mode", "", 1)}}中,但不排除其他情况)。</p> @@ -39,7 +39,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/preventExtensions <p>一旦将对象变为不可扩展的对象,就再也不能使其可扩展。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <pre class="brush: js">// Object.preventExtensions将原对象变的不可扩展,并且返回原对象. var obj = {}; @@ -117,7 +117,7 @@ Object.preventExtensions(1); <p>{{Compat("javascript.builtins.Object.preventExtensions")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.isExtensible()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/seal/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/seal/index.html index 69d14321ee..ad57d66c17 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/seal/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/seal/index.html @@ -18,11 +18,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/seal -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Object.seal(<em>obj</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>obj</code></dt> @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/seal <p>被密封的对象。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>通常,一个对象是{{jsxref("Object.isExtensible()", "可扩展的", "", 1)}}(可以添加新的属性)。密封一个对象会让这个对象变的不能添加新属性,且所有已有属性会变的不可配置。属性不可配置的效果就是属性变的不可删除,以及一个数据属性不能被重新定义成为访问器属性,或者反之。但属性的值仍然可以修改。尝试删除一个密封对象的属性或者将某个密封对象的属性从数据属性转换成访问器属性,结果会静默失败或抛出{{jsxref("TypeError")}}(在{{jsxref("Strict_mode", "严格模式", "", 1)}} 中最常见的,但不唯一)。</p> @@ -41,7 +41,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/seal <p>返回被密封对象的引用。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <pre class="brush: js">var obj = { prop: function() {}, @@ -132,7 +132,7 @@ Object.seal(1); </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容</h2> +<h2 id="Browser_compatibility">浏览器兼容</h2> <div> @@ -140,7 +140,7 @@ Object.seal(1); <p>{{Compat("javascript.builtins.Object.seal")}}</p> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.isSealed()")}}</li> 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 cf2df7e50d..06de1bcc7c 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 @@ -24,11 +24,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf <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" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Object.setPrototypeOf(<em>obj, prototype</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt>obj</dt> @@ -37,7 +37,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf <dd>该对象的新原型(一个对象 或 {{jsxref("null")}}).</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果对象的[[Prototype]]被修改成不可扩展(通过 {{jsxref("Object.isExtensible()")}}查看),就会抛出 {{jsxref("TypeError")}}异常。如果<code>prototype</code>参数不是一个对象或者{{jsxref("null")}}(例如,数字,字符串,boolean,或者 {{jsxref("undefined")}}),则什么都不做。否则,该方法将<code>obj</code>的<code>[[Prototype]]</code>修改为新的值。</p> @@ -47,7 +47,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf <pre><code>var dict = Object.setPrototypeOf({}, null);</code></pre> -<h2 id="Notes" name="Notes">Polyfill</h2> +<h2 id="Notes">Polyfill</h2> <p>我们必须借助非标准的 </p> @@ -219,7 +219,7 @@ george(); // 'Hello guys!!'</pre> <div></div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Reflect.setPrototypeOf()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/tolocalestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/tolocalestring/index.html index 8d5a9d6538..bb3ec0e756 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/tolocalestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/tolocalestring/index.html @@ -12,7 +12,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/toLocaleString <p><code><strong>toLocaleString()</strong></code> 方法返回一个该对象的字符串表示。此方法被用于派生对象为了特定语言环境的目的(locale-specific purposes)而重载使用。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>obj</var>.toLocaleString();</code> </pre> @@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/toLocaleString <p>表示对象的字符串。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Object")}} <code>toLocaleString</code> 返回调用 {{jsxref("Object.toString", "toString()")}} 的结果。</p> @@ -71,7 +71,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/toLocaleString <p>{{Compat("javascript.builtins.Object.toLocaleString")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.toString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/tosource/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/tosource/index.html index e609077520..5713289596 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/tosource/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/tosource/index.html @@ -14,15 +14,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/toSource <p><strong><code>toSource()</code></strong>方法返回一个表示对象源代码的字符串。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>Object.toSource(); obj</em>.toSource()</code></pre> -<h3 id="Parameters" name="Parameters">返回值</h3> +<h3 id="Parameters">返回值</h3> <p>一个表示对象的源代码的字符串。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>toSource()</code>方法返回以下值:</p> @@ -54,7 +54,7 @@ Person.prototype.toSource = function Person_toSource() { alert(new Person("Joe").toSource()); // ---> new Person("Joe")</pre> -<h3 id="Built-in_toString_methods" name="Built-in_toString_methods">内置<code>的toSource方法</code></h3> +<h3 id="Built-in_toString_methods">内置<code>的toSource方法</code></h3> <p>每个JavaScript核心类型都有它自己的<code>toSource()</code>方法.这些对象是:</p> @@ -89,9 +89,9 @@ console.log('Cyclical: ' + (obj1.b.a == obj1));</pre> <p>如果使用循环结构, 并且需要 <code>toSource()</code>, 则对象必须提供对 <code>toSource()</code> 的重写, 无论是对构造函数的引用还是提供匿名函数。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Using_toSource" name="Example:_Using_toSource">使用<code>toSource()</code></h3> +<h3 id="Example:_Using_toSource">使用<code>toSource()</code></h3> <p>下面的代码定义了一个<code>Dog</code>对象类型还创建了一个<code>Dog</code>类型的对象实例<code>theDog</code>:</p> @@ -117,7 +117,7 @@ theDog = new Dog("Gabby", "Lab", "chocolate", "girl");</pre> <p>{{Compat("javascript.builtins.Object.toSource")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.toString()")}}</li> 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 82d2bc61d9..1067350917 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 @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/valueOf <p><code><strong>valueOf()</strong></code> 方法返回指定对象的原始值。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre>object.valueOf()</pre> @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/valueOf <p>返回值为该对象的原始值。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>JavaScript调用<code>valueOf</code>方法将对象转换为原始值。你很少需要自己调用<code>valueOf</code>方法;当遇到要预期的原始值的对象时,JavaScript会自动调用它。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/parsefloat/index.html b/files/zh-cn/web/javascript/reference/global_objects/parsefloat/index.html index f32b3bbf90..eaa80b6179 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/parsefloat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/parsefloat/index.html @@ -113,7 +113,7 @@ parseFloat('900719925474099267n');</pre> <p>{{Compat("javascript.builtins.parseFloat")}}</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Global_Objects/parseInt", "parseInt()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/parseint/index.html b/files/zh-cn/web/javascript/reference/global_objects/parseint/index.html index fad8f4e3cc..9a631e1e4f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/parseint/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/parseint/index.html @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/parseInt <pre>parseInt('123', 5) // 将'123'看作5进制数,返回十进制数38 => 1*5^2 + 2*5^1 + 3*5^0 = 38</pre> -<h2 id="描述_2"><a name="描述">描述</a></h2> +<h2 id="描述_2"><a>描述</a></h2> <p><code>parseInt</code>函数将其第一个参数转换为一个字符串,对该字符串进行解析,然后返回一个整数或 <code>NaN</code>。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/promise/catch/index.html b/files/zh-cn/web/javascript/reference/global_objects/promise/catch/index.html index addf056e90..2beb165c9f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/promise/catch/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/promise/catch/index.html @@ -10,7 +10,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/catch <p><strong>catch()</strong> 方法返回一个<a href="/zh-CN/docs/Web/API/Promise">Promise</a>,并且处理拒绝的情况。它的行为与调用{{jsxref("Promise.then", "Promise.prototype.then(undefined, onRejected)")}} 相同。 (事实上, calling <code>obj.catch(onRejected)</code> 内部calls <code>obj.then(undefined, onRejected)</code>).</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>p.catch(onRejected)</var>; @@ -34,7 +34,7 @@ p.catch(function(reason) { </dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>catch </code>方法可以用于您的promise组合中的错误处理。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/promise/race/index.html b/files/zh-cn/web/javascript/reference/global_objects/promise/race/index.html index 674d97f5e1..a04b386330 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/promise/race/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/promise/race/index.html @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/race <div>{{EmbedInteractiveExample("pages/js/promise-race.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>Promise.race(iterable)</var>;</pre> @@ -26,7 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/race <p>一个<strong>待定的</strong> {{jsxref("Promise")}} 只要给定的迭代中的一个promise解决或拒绝,就采用第一个promise的值作为它的值,从而<strong>异步</strong>地解析或拒绝(一旦堆栈为空)。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>race</code> 函数返回一个 <code>Promise</code>,它将与第一个传递的 promise 相同的完成方式被完成。它可以是完成( resolves),也可以是失败(rejects),这要取决于第一个完成的方式是两个中的哪个。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/promise/reject/index.html b/files/zh-cn/web/javascript/reference/global_objects/promise/reject/index.html index aff5a4047b..d733feaa6a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/promise/reject/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/promise/reject/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/reject <p>{{EmbedInteractiveExample("pages/js/promise-reject.html")}}</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>Promise.reject(reason)</var>;</pre> @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/reject <dd>一个给定原因了的被拒绝的 {{jsxref("Promise")}}。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>静态函数<code>Promise.reject</code>返回一个被拒绝的<code>Promise对象</code>。通过使用{{jsxref("Error")}}的实例获取错误原因<code>reason</code>对调试和选择性错误捕捉很有帮助。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/promise/resolve/index.html b/files/zh-cn/web/javascript/reference/global_objects/promise/resolve/index.html index e25c58139a..cce699c0bc 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/promise/resolve/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/promise/resolve/index.html @@ -31,7 +31,7 @@ Promise.resolve(thenable) //这会造成一个死循环 <div>{{EmbedInteractiveExample("pages/js/promise-resolve.html")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>Promise.resolve(value)</var>; </pre> @@ -48,7 +48,7 @@ Promise.resolve(thenable) //这会造成一个死循环 <p>返回一个带着给定值解析过的<code>Promise</code>对象,如果参数本身就是一个<code>Promise</code>对象,则直接返回这个<code>Promise</code>对象。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>静态方法 <code>Promise.resolve</code>返回一个解析过的<code>Promise</code>对象。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/referenceerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/referenceerror/index.html index bcc37e33e3..2dcc165e43 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/referenceerror/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/referenceerror/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError --- <div>{{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>ReferenceError(引用错误)</strong></code> 对象代表当一个不存在的变量被引用时发生的错误。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>new ReferenceError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>message</code></dt> @@ -24,34 +24,34 @@ translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError <dd>可选。引起异常的代码行号</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>当你尝试引用一个未被定义的变量时,将会抛出一个 <code>ReferenceError</code> 。</p> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt>{{jsxref("ReferenceError.prototype")}}</dt> <dd>Allows the addition of properties to an <code>ReferenceError</code> object.</dd> </dl> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <p>全局的 <code>ReferenceError</code> 本身并不包含有方法,但是他可以从原型链上继承一些方法</p> -<h2 id="ReferenceError_instances" name="ReferenceError_instances"><code>ReferenceError</code> 实例</h2> +<h2 id="ReferenceError_instances"><code>ReferenceError</code> 实例</h2> -<h3 id="Properties_of_ReferenceError_instances" name="Properties_of_ReferenceError_instances">属性</h3> +<h3 id="Properties_of_ReferenceError_instances">属性</h3> <div>{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype', 'Properties')}}</div> -<h3 id="Methods_of_ReferenceError_instances" name="Methods_of_ReferenceError_instances">方法</h3> +<h3 id="Methods_of_ReferenceError_instances">方法</h3> <div>{{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype', 'Methods')}}</div> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> -<h3 id="Example:_Catch_an_ReferenceError" name="Example:_Catch_an_ReferenceError">例: 捕获一个 <code>ReferenceError</code></h3> +<h3 id="Example:_Catch_an_ReferenceError">例: 捕获一个 <code>ReferenceError</code></h3> <pre class="brush: js">try { var a = undefinedVariable; @@ -66,7 +66,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError } </pre> -<h3 id="Example:_Create_an_ReferenceError" name="Example:_Create_an_ReferenceError">例: 创建一个 <code>ReferenceError</code></h3> +<h3 id="Example:_Create_an_ReferenceError">例: 创建一个 <code>ReferenceError</code></h3> <pre class="brush: js">try { throw new ReferenceError('Hello', 'someFile.js', 10); @@ -160,7 +160,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Error")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/exec/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/exec/index.html index 8ee22ffa6c..549dd3d494 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/exec/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/exec/index.html @@ -22,18 +22,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/exec -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>regexObj</var>.exec(<var>str</var>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>str</code></dt> <dd>要匹配正则表达式的字符串。</dd> </dl> -<h3 id="Description" name="Description">返回值</h3> +<h3 id="Description">返回值</h3> <p>如果匹配成功,<code>exec()</code> 方法返回一个数组(包含额外的属性 <code>index</code> 和 <code>input</code> ,参见下方表格),并更新正则表达式对象的 {{jsxref("RegExp.lastIndex", "lastIndex")}} 属性。完全匹配成功的文本将作为返回数组的第一项,从第二项起,后续每项都对应正则表达式内捕获括号里匹配成功的文本。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/global/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/global/index.html index 9ac9219ec2..95fbabc9d0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/global/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/global/index.html @@ -10,15 +10,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/global --- <div> {{JSRef("Global_Objects", "RegExp")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>global</strong></code> 属性表明正则表达式是否使用了 "<code>g</code>" 标志。<code>global</code> 是一个正则表达式实例的只读属性。</p> <div> {{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>global</code> 的值是布尔对象,如果使用了 "<code>g</code>" 标志,则返回 <code>true</code>;否则返回 <code>false</code>。 "<code>g</code>" 标志意味着正则表达式应该测试字符串中所有可能的匹配。</p> <p>你无法直接更改此属性。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_MIN_VALUE" name="Example:_Using_MIN_VALUE">例子:使用 <code>global</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_MIN_VALUE">例子:使用 <code>global</code></h3> <pre class="brush:js">var regex = new RegExp("foo", "g") console.log(regex.global) // true @@ -97,7 +97,7 @@ console.log(regex.global) // true </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("RegExp.prototype.ignoreCase")}}</li> <li>{{jsxref("RegExp.prototype.lastIndex")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/ignorecase/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/ignorecase/index.html index 7492cf627e..c1802df75a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/ignorecase/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/ignorecase/index.html @@ -10,15 +10,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/ignoreCase --- <div> {{JSRef("Global_Objects", "RegExp")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>ignoreCase</strong></code> 属性表明正则表达式是否使用了 "<code>i</code>" 标志。<code>ignoreCase</code> 是正则表达式实例的只读属性。</p> <div> {{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>ignoreCase</code> 的值是布尔对象,如果使用了"<code>i</code>" 标志,则返回 <code>true</code>;否则,返回 <code>false</code>。"<code>i</code>" 标志意味着在字符串进行匹配时,应该忽略大小写。</p> <p>你无法直接更改此属性。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_MIN_VALUE" name="Example:_Using_MIN_VALUE">例子:使用 <code>ignoreCase</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_MIN_VALUE">例子:使用 <code>ignoreCase</code></h3> <pre class="brush:js">var regex = new RegExp("foo", "i") console.log(regex.ignoreCase) // true @@ -97,7 +97,7 @@ console.log(regex.ignoreCase) // true </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("RegExp.prototype.global")}}</li> <li>{{jsxref("RegExp.prototype.lastIndex")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/index.html index a0bcd500de..25f587ed4c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/index.html @@ -115,9 +115,9 @@ var re = /\w+/;</pre> <dd>返回表示指定对象的字符串。重写{{jsxref("Object.prototype.toString()")}}方法。</dd> </dl> -<h2 id="Syntax" name="Syntax">示例</h2> +<h2 id="Syntax">示例</h2> -<h3 id="Using_a_regular_expression_to_change_data_format" name="Using_a_regular_expression_to_change_data_format">使用正则改变数据结构</h3> +<h3 id="Using_a_regular_expression_to_change_data_format">使用正则改变数据结构</h3> <p>下例使用 {{jsxref("Global_Objects/String", "String")}} 的 {{jsxref("String.prototype.replace()", "replace()")}} 方法去匹配姓名 <em>first last </em>输出新的格式 <em>last</em>, <em>first</em>。</p> @@ -152,7 +152,7 @@ s.match(/yes.*day/); s.match(/yes[^]*day/); // Returns 'yes\nmake my day'</pre> -<h3 id="Using_a_regular_expression_with_the_sticky_flag" name="Using_a_regular_expression_with_the_sticky_flag">使用带有 sticky 标志的正则表达式</h3> +<h3 id="Using_a_regular_expression_with_the_sticky_flag">使用带有 sticky 标志的正则表达式</h3> <p>带有{{JSxRef("Global_Objects/RegExp/sticky", "sticky")}}标志的正则表达式将会从源字符串的{{jsxref("RegExp.prototype.lastIndex")}}位置开始匹配,也就是进行“粘性匹配”。</p> @@ -179,7 +179,7 @@ while (r = re.exec("123 456")) console.log(r, "AND re.lastIndex", re.lastIndex); <p>如果使用带有全局标志<code>g</code>的正则表达式<code>re</code>,就会捕获字符串中的所有6个数字,而非3个</p> -<h3 id="Browser_Compatibility" name="Browser_Compatibility">使用正则表达式和 Unicode 字符</h3> +<h3 id="Browser_Compatibility">使用正则表达式和 Unicode 字符</h3> <p>正如上面表格提到的,<code>\w</code> 或 <code>\W</code> 只会匹配基本的 ASCII 字符;如 <code>a</code> 到 <code>z</code>、 <code>A</code> 到 <code>Z</code>、 <code>0</code> 到 <code>9</code> 及 <code>_</code>。</p> @@ -240,7 +240,7 @@ console.log(/[^.]+/.exec(url)[0].substr(7)); // logs "xxx" </tbody> </table> -<h2 id="Browser_Compatibility" name="Browser_Compatibility">浏览器兼容性</h2> +<h2 id="Browser_Compatibility">浏览器兼容性</h2> <p>{{Compat("javascript.builtins.RegExp")}}</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/lastindex/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/lastindex/index.html index 92dadc8159..ddfe60c595 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/lastindex/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/lastindex/index.html @@ -10,13 +10,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex --- <div> {{JSRef("Global_Objects", "RegExp")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>lastIndex</strong></code> 是正则表达式的一个可读可写的整型属性,用来指定下一次匹配的起始索引。</p> <div> {{js_property_attributes(1,0,0)}}</div> <h2 id="语法">语法</h2> <pre class="syntaxbox language-html"><var>lastIndex</var> = <var>regExpObj</var>.lastIndex;</pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>只有正则表达式使用了表示全局检索的 "<code>g</code>" 标志时,该属性才会起作用。此时应用下面的规则:</p> <ul> <li>如果 <code>lastIndex</code> 大于字符串的长度,则 <code>regexp.test</code> 和 <code>regexp.exec</code> 将会匹配失败,然后 <code>lastIndex</code> 被设置为 0。</li> @@ -111,7 +111,7 @@ console.log(re.lastIndex);</pre> </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("RegExp.prototype.ignoreCase")}}</li> <li>{{jsxref("RegExp.prototype.global")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/multiline/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/multiline/index.html index 3405a93a1d..54b99c15ad 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/multiline/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/multiline/index.html @@ -11,15 +11,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/multiline --- <div> {{JSRef("Global_Objects", "RegExp")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>multiline</strong></code> 属性表明正则表达式是否使用了 "<code>m</code>" 标志。<code>multiline</code> 是正则表达式实例的一个只读属性。</p> <div> {{js_property_attributes(0,0,0)}}</div> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>multiline</code> 是一个布尔对象,如果使用了 "<code>m</code>" 标志,则返回 <code>true</code>;否则,返回 <code>false</code>。"<code>m</code>" 标志意味着一个多行输入字符串被看作多行。例如,使用 "<code>m</code>","<code>^</code>" 和 "<code>$</code>" 将会从只匹配正则字符串的开头或结尾,变为匹配字符串中任一行的开头或结尾。</p> <p>你无法直接更改此属性。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_MIN_VALUE" name="Example:_Using_MIN_VALUE">例子:使用 <code>multiline</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_MIN_VALUE">例子:使用 <code>multiline</code></h3> <pre class="brush:js">var regex = new RegExp("foo", "m") console.log(regex.multiline) // true @@ -98,7 +98,7 @@ console.log(regex.multiline) // true </tbody> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("RegExp.prototype.global")}}</li> <li>{{jsxref("RegExp.prototype.lastIndex")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/source/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/source/index.html index 3bd290c609..191f1e0feb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/source/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/source/index.html @@ -12,18 +12,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/source --- <div>{{JSRef("Global_Objects", "RegExp")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><strong><code>source</code></strong> 属性返回一个值为当前正则表达式对象的模式文本的字符串,该字符串不会包含正则字面量两边的斜杠以及任何的标志字符。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">var regex = /fooBar/ig; console.log(regex.source); // "fooBar",不包含 /.../ 和 "ig"。 </pre> -<h2 id="Specifications" name="Specifications">规范</h2> +<h2 id="Specifications">规范</h2> <table class="standard-table"> <tbody> @@ -50,7 +50,7 @@ console.log(regex.source); // "fooBar",不包含 /.../ 和 "ig"。 </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div>{{CompatibilityTable}}</div> @@ -102,7 +102,7 @@ console.log(regex.source); // "fooBar",不包含 /.../ 和 "ig"。 </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("RegExp.prototype.flags")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/test/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/test/index.html index 8bd8126956..3bb032ce00 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/test/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/test/index.html @@ -15,11 +15,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/test <div>{{EmbedInteractiveExample("pages/js/regexp-prototype-test.html", "taller")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre><var>regexObj</var>.test(str)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>str</code></dt> @@ -30,13 +30,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/test <p>如果正则表达式与指定的字符串匹配 ,返回<code>true</code>;否则<code>false</code>。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>当你想要知道一个正则表达式是否与指定的字符串匹配时,就可以使用 <code>test()</code>(类似于<code> </code> {{jsxref("String.prototype.search()")}} 方法),差别在于test返回一个布尔值,而 search 返回索引(如果找到)或者-1(如果没找到);若想知道更多信息(然而执行比较慢),可使用{{jsxref("RegExp.prototype.exec()", "exec()")}} 方法(类似于 {{jsxref("String.prototype.match()")}} 方法)。 和 {{jsxref("RegExp.prototype.exec()", "exec()")}} (或者组合使用),一样,在相同的全局正则表达式实例上多次调用<code><code>test</code></code>将会越过之前的匹配。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_test" name="Example:_Using_test">使用 <code>test()</code></h3> +<h3 id="Example_Using_test">使用 <code>test()</code></h3> <p>一个简单的例子,测试 "hello" 是否包含在字符串的最开始,返回布尔值。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/tosource/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/tosource/index.html index 80f4972ca0..3e86a9020d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/tosource/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/tosource/index.html @@ -11,16 +11,16 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/toSource --- <p>{{JSRef("Global_Objects", "RegExp")}}{{ Non-standard_header() }}</p> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p>返回一个字符串,代表当前对象的源代码</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>regexObj</var>.toSource() </code></pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>toSource</code>方法返回值如下:</p> @@ -39,6 +39,6 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/toSource <p>该方法通常由JavaScript内部隐含调用,而不会明确的出现在用户代码中.</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <p><a href="/zh-cn/JavaScript/Reference/Global_Objects/Object/toSource" title="zh-cn/JavaScript/Reference/Global_Objects/Object/toSource">Object.prototype.toSource</a></p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/tostring/index.html index 86322dbc18..a1007ec670 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/tostring/index.html @@ -10,16 +10,16 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/toString --- <div> {{JSRef("Global_Objects", "RegExp")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>toString()</strong></code> 返回一个表示该正则表达式的字符串。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>regexObj</var>.toString()</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <p>无</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Global_Objects/RegExp", "RegExp")}} 对象覆盖了 {{jsxref("Global_Objects/Object", "Object")}} 对象的 <code>toString()</code> 方法,并没有继承 {{jsxref("Object.prototype.toString()")}}。对于 <code>RegExp</code> 对象,<code>toString</code> 方法返回一个该正则表达式的字符串形式。</p> -<h2 id="Examples" name="Examples">示例</h2> -<h3 id="Example:_Using_toString" name="Example:_Using_toString">例子:使用 <code>toString</code></h3> +<h2 id="Examples">示例</h2> +<h3 id="Example:_Using_toString">例子:使用 <code>toString</code></h3> <p>下例输出 <code>RegExp</code> 对象的字符串值:</p> <pre>myExp = new RegExp("a+b+c"); alert(myExp.toString()); // 显示 "/a+b+c/" @@ -100,7 +100,7 @@ alert(foo.toString()); // 显示 "/bar/g" </tbody> </table> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.toString()")}}</li> </ul> diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/add/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/add/index.html index dac50ccb29..f52634dde9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/set/add/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/set/add/index.html @@ -18,7 +18,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/add -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>mySet</em>.add(value);</code></pre> @@ -35,7 +35,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/add <p>注意:不能添加重复的值</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">var mySet = new Set(); diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/clear/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/clear/index.html index de14cee47c..b8df81ca52 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/set/clear/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/set/clear/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/clear <p><code><strong>clear()</strong></code> 方法用来清空一个 <code>Set</code> 对象中的所有元素。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>mySet</em>.clear();</code> </pre> @@ -23,7 +23,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/clear <p>{{jsxref("undefined")}}.</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">var mySet = new Set(); mySet.add(1); diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/delete/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/delete/index.html index 3d11a91183..92eef27f5f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/set/delete/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/set/delete/index.html @@ -12,7 +12,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/delete <p><code><strong>delete()</strong></code> 方法可以从一个 <code>Set</code> 对象中删除指定的元素。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>mySet</em>.delete(value);</code></pre> @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/delete <p>成功删除返回 <code>true</code>,否则返回 <code>false。</code></p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">var mySet = new Set(); mySet.add("foo"); @@ -112,7 +112,7 @@ mySet.has("foo"); // 返回 false,"foo" 已经成功删除 </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Set")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/has/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/has/index.html index 47369b1f27..0174ccd5bc 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/set/has/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/set/has/index.html @@ -9,11 +9,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/has --- <div>{{JSRef("Global_Objects", "Set")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><strong>has() </strong>方法返回一个布尔值来指示对应的值value是否存在Set对象中。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>mySet</em>.has(value);</code></pre> @@ -31,9 +31,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/has <dd>如果指定的值(value)存在于Set对象当中,返回<code>true</code>;否则返回 <code>false</code>。</dd> </dl> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Testing_size_of_all_array_elements" name="Example:_Testing_size_of_all_array_elements">使用 <code>has</code> 方法</h3> +<h3 id="Example:_Testing_size_of_all_array_elements">使用 <code>has</code> 方法</h3> <pre class="brush: js line-numbers language-js">var mySet = new Set(); mySet.add('foo'); diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/index.html index df4e5fbf4c..23e07ae834 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/set/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/set/index.html @@ -37,7 +37,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set <dd>构造函数用来创建派生对象.</dd> </dl> -<h2 id="Properties" name="Properties">实例属性</h2> +<h2 id="Properties">实例属性</h2> <dl> <dt>{{jsxref("Set.prototype.size")}}</dt> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/anchor/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/anchor/index.html index b48e62e0f8..43ab947d68 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/anchor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/anchor/index.html @@ -129,7 +129,7 @@ document.body.innerHTML = myString.anchor("contents_anchor");</pre> <p>从{{gecko("17")}}开始 <strong>"</strong> (引号) 被 HTML引用字符 <code>&quot所替代</code>;在字符串中申请<code>命名参数</code>.</p> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("String.prototype.link()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/charat/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/charat/index.html index 31b512ada0..ab72e58c81 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/charat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/charat/index.html @@ -7,15 +7,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/charAt --- <p>{{JSRef}}</p> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><strong>charAt()</strong> 方法从一个字符串中返回指定的字符。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><em>str</em>.charAt(<em>index</em>)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>index</code></dt> @@ -24,13 +24,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/charAt <dt> </dt> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>字符串中的字符从左向右索引,第一个字符的索引值为 0,最后一个字符(假设该字符位于字符串 stringName 中)的索引值为 <code>stringName.length - 1</code>。 如果指定的 index 值超出了该范围,则返回一个空字符串。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Displaying_characters_at_different_locations_in_a_string" name="Example:_Displaying_characters_at_different_locations_in_a_string">例子:输出字符串中不同位置的字符</h3> +<h3 id="Example:_Displaying_characters_at_different_locations_in_a_string">例子:输出字符串中不同位置的字符</h3> <p>下例输出字符串 "<code>Brave new world</code>" 不同位置处的字符:</p> @@ -269,7 +269,7 @@ function getWholeCharAndI (str, i) { </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("String.prototype.indexOf()")}}, {{jsxref("String.prototype.lastIndexOf()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/charcodeat/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/charcodeat/index.html index e0c7b1168f..ad5bd693df 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/charcodeat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/charcodeat/index.html @@ -49,9 +49,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/charCodeAt <p>向后兼容:在历史版本中(如 JavaScript 1.2),<code>charCodeAt</code> 返回一个数字,表示给定 index 处字符的 ISO-Latin-1 编码值。ISO-Latin-1 编码集范围从 <code>0</code> 到 <code>255</code>。开头的 <code>0</code> 到 <code>127</code> 直接匹配 ASCII 字符集。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_charCodeAt" name="Example:_Using_charCodeAt">使用 <code>charCodeAt()</code></h3> +<h3 id="Example_Using_charCodeAt">使用 <code>charCodeAt()</code></h3> <p>下例介绍了不同索引情况下返回的 Unicode 值:</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/concat/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/concat/index.html index 1f2e37ceb4..09efff146b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/concat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/concat/index.html @@ -12,11 +12,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/concat <p><strong><code>concat()</code></strong> 方法将一个或多个字符串与原字符串连接合并,形成一个新的字符串并返回。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre><code><var>str</var>.concat(<var>str2</var>, [, ...<var>strN</var>])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code><var>str2</var> [, ...<var>strN</var>]</code></dt> @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/concat <p>一个新的字符串,包含参数所提供的连接字符串。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>concat</code> 方法将一个或多个字符串与原字符串连接合并,形成一个新的字符串并返回。 <code>concat</code> 方法并不影响原字符串。</p> @@ -37,9 +37,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/concat <p>强烈建议使用<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Assignment_Operators">赋值操作符</a>(<code>+</code>, <code>+=</code>)代替 <code>concat</code> 方法。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Examples" name="Examples">使用 <code>concat</code></h3> +<h3 id="Examples">使用 <code>concat</code></h3> <p>下面的例子演示如何将多个字符串与原字符串合并为一个新字符串</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/fromcharcode/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/fromcharcode/index.html index 3ac0a6a122..99e3827daa 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/fromcharcode/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/fromcharcode/index.html @@ -14,11 +14,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/fromCharCode -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>String.fromCharCode(<var>num1</var>[, ...[, <var>numN</var>]])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>num1, ..., num<em>N</em></code></dt> @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/fromCharCode <p>一个长度为 <code>N</code> 的字符串,由 <code>N</code> 个指定的 UTF-16 代码单元组成。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>该方法返回一个字符串,而不是一个 {{jsxref("String")}} 对象。</p> @@ -81,7 +81,7 @@ String.fromCharCode(0xD834, 0xDF06, 0x61, 0xD834, 0xDF07); // "\uD834\uDF06a\uD8 <p>{{Compat("javascript.builtins.String.fromCharCode")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("String.prototype.charCodeAt()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/includes/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/includes/index.html index 672a34166f..6784bfb61f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/includes/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/includes/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/includes <p><strong><code>includes()</code> </strong>方法用于判断一个字符串是否包含在另一个字符串中,根据情况返回 true 或 false。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>str</var>.includes(<var>searchString</var>[, <var>position</var>])</pre> @@ -60,7 +60,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/includes }; }</code></pre> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="使用_includes">使用 includes()</h3> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/index.html index bcfc0bf5ec..6b8d96b0ac 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/index.html @@ -12,7 +12,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String <p><strong><code>String</code></strong> 全局对象是一个用于字符串或一个字符序列的构造函数。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <p>字符串字面量采取以下形式:</p> @@ -35,20 +35,20 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String <pre class="syntaxbox">String(thing) new String(thing)</pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>thing</code></dt> <dd>任何可以被转换成字符串的值。</dd> </dl> -<h3 id="Parameters" name="Parameters">模板字面量</h3> +<h3 id="Parameters">模板字面量</h3> <p>从 ECMAScript 2015 开始,字符串字面量也可以称为<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals">模板字面量</a>:</p> <pre>`hello world` `hello! world!` `hello ${who}` escape `<a>${who}</a>`</pre> -<h3 id="Parameters" name="Parameters">转义字符</h3> +<h3 id="Parameters">转义字符</h3> <dl> </dl> @@ -141,11 +141,11 @@ otherwise my code is unreadable.";</code></pre> <dl> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>字符串对于保存可以以文本形式表示的数据非常有用。 一些常用的字符串操作有:查询<a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/length">字符串长度</a>,使用<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/String_Operators"> + 和 += </a>运算符来构建和连接字符串,使用 <a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf">indexOf</a> 方法检查某一子字符串在父字符串中的位置,又或是使用 <a href="/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/substring">substring</a> 方法提取从父字符串中提取子字符串。</p> -<h3 id="Character_access" name="Character_access">从字符串中获取单个字符</h3> +<h3 id="Character_access">从字符串中获取单个字符</h3> <p>获取字符串的某个字符有两种方法。 第一种是使用 {{jsxref("String.charAt", "charAt")}} 方法:</p> @@ -159,7 +159,7 @@ otherwise my code is unreadable.";</code></pre> <p>使用括号访问字符串不可以对其进行删除或添加,因为字符串对应未知的属性并不是可读或配置的。 (更多的信息请参阅 {{jsxref("Object.defineProperty")}}。 )</p> -<h3 id="Comparing_strings" name="Comparing_strings">字符串比较</h3> +<h3 id="Comparing_strings">字符串比较</h3> <p>熟练使用 C 语言的开发者经常使用 <code>strcmp</code> 函数来比较字符串,但在 JavaScript 中,你只需要使用<a href="/zh-CN/docs/Web/JavaScript/Reference/Operators/Comparison_Operators">比较操作符(>/</>=/<=)</a>:</p> @@ -212,7 +212,7 @@ console.log(eval(s2)); // returns the string "2 + 2" <dd>可以为 String 对象增加新的属性。</dd> </dl> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <dl> <dt>{{jsxref("String.fromCharCode()")}} </dt> @@ -247,7 +247,7 @@ console.log(String.replace(num, /5/, '2')); <p class="brush: js">{{jsxref("Global_Objects/Array", "Generics", "#Array_generic_methods", 1)}} 在 Javascript 1.6 中同样支持{{jsxref("Global_Objects/Array", "Array")}}。</p> -<h2 id="String_instances" name="String_instances"><code>String</code> 实例</h2> +<h2 id="String_instances"><code>String</code> 实例</h2> <h3 id="属性_2">属性</h3> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/indexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/indexof/index.html index 28f9d9a5fc..40fceeeadd 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/indexof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/indexof/index.html @@ -84,7 +84,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/indexOf <h2 id="示例">示例</h2> -<h3 id="Example_Using_indexOf_and_lastIndexOf" name="Example:_Using_indexOf_and_lastIndexOf">使用<code>indexOf()</code> 和 <code>lastIndexOf()</code></h3> +<h3 id="Example_Using_indexOf_and_lastIndexOf">使用<code>indexOf()</code> 和 <code>lastIndexOf()</code></h3> <p>下例使用 <code>indexOf()</code> 和 <code>lastIndexOf()</code> 方法定位字符串中 "<code>Brave new world</code>" 的值。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/lastindexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/lastindexof/index.html index 56ba74598a..297d9f6d89 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/lastindexof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/lastindexof/index.html @@ -9,11 +9,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf <p>该方法将从尾到头地检索字符串 <em>str</em>,看它是否含有子串 <em>searchValue</em>。开始检索的位置在字符串的 <em>fromIndex</em> 处或字符串的结尾(没有指定 <em>fromIndex</em> 时)。如果找到一个 <em>searchValue</em>,则返回 <em>searchValue</em> 的第一个字符在 <em>str</em> 中的位置。<em>str</em>中的字符位置是从 0 开始的。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>str</em>.lastIndexOf(<em>searchValue</em>[, fromIndex])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>searchValue</code></dt> @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf <p>返回指定值最后一次出现的索引(该索引仍是以从左至右0开始记数的),如果没找到则返回-1。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>字符串中的字符被从左向右索引。首字符的索引(index)是 0,最后一个字符的索引是 <code>stringName.length - 1</code>。</p> @@ -47,15 +47,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf <p>(例如'abadefgabm'.lastIndexOf('ab', 7) 返回7,虽然查找的'ab'中的b已经在 index=8的位置了从index=7的a处向左查找仍是能找到自身a加上其后连成ab,因为fromIndex指的是待匹配字符串的开头那一个)</p> -<h3 id="Example_indexOf_and_case-sensitivity" name="Example:_indexOf_and_case-sensitivity">区分大小写</h3> +<h3 id="Example_indexOf_and_case-sensitivity">区分大小写</h3> <p><code>lastIndexOf</code> 方法区分大小写。例如,下面的表达式返回 -1:</p> <pre class="brush:js">"Blue Whale, Killer Whale".lastIndexOf("blue"); // returns -1</pre> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_indexOf_and_lastIndexOf" name="Example:_Using_indexOf_and_lastIndexOf">例子:使用 <code>indexOf</code> 和 <code>lastIndexOf</code></h3> +<h3 id="Example_Using_indexOf_and_lastIndexOf">例子:使用 <code>indexOf</code> 和 <code>lastIndexOf</code></h3> <p>下例使用 <code>indexOf</code> 和 <code>lastIndexOf</code> 方法来定位字符串 "<code>Brave new world</code>" 中的值。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/length/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/length/index.html index bf49c313f0..afef2dd204 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/length/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/length/index.html @@ -10,11 +10,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/length --- <p>{{JSRef("Global_Objects", "String")}}</p> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><strong>length</strong> 属性表示一个字符串的长度。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>该属性返回字符串中字符编码单元的数量。JavaScript 使用 {{ interwiki("wikipedia", "UTF-16") }} 编码,该编码使用一个 16 比特的编码单元来表示大部分常见的字符,使用两个代码单元表示不常用的字符。因此 length 返回值可能与字符串中实际的字符数量不相同。</p> @@ -22,7 +22,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/length <p>静态属性 <strong>String.length</strong> 返回 1。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js">var x = "Mozilla"; var empty = ""; @@ -112,7 +112,7 @@ console.log("The empty string is has a length of " + empty.length); </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li><a class="external external-icon" href="http://developer.teradata.com/blog/jasonstrimpel/2011/11/javascript-string-length-and-internationalizing-web-applications">JavaScript String.length and Internationalizing Web Applications</a></li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/link/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/link/index.html index ed9faa514e..2ca4055211 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/link/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/link/index.html @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/link <p>使用 <code>link</code> 方法创建的链接将会成为 document.links 数组中的元素。查看 {{ Domxref("document.links") }}。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="例子:使用_link">例子:使用 <code>link</code></h3> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html index f369a7a7f9..57bd74a182 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/match/index.html @@ -10,11 +10,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match <div>{{EmbedInteractiveExample("pages/js/string-match.html", "shorter")}}</div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>str</em>.match(regexp)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>regexp</code></dt> @@ -42,11 +42,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match <dd>一个{{jsxref("Array")}},其内容取决于global(<code>g</code>)标志的存在与否,如果未找到匹配则为{{jsxref("null")}}。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>如果正则表达式不包含 <code>g </code>标志,<code>str.match()</code> 将返回与 {{jsxref("RegExp.prototype.exec()", "RegExp.exec()")}}. 相同的结果。</p> -<h3 id="Notes" name="Notes">参看:<code>RegExp</code> 方法</h3> +<h3 id="Notes">参看:<code>RegExp</code> 方法</h3> <ul> <li>如果你需要知道一个字符串是否与一个正则表达式匹配 {{jsxref("RegExp")}} ,可使用 {{jsxref("RegExp.prototype.test()", "RegExp.test()")}} 。</li> @@ -54,9 +54,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match <li>如果你想要获得捕获组,并且设置了全局标志,你需要用 {{jsxref("RegExp.prototype.exec()", "RegExp.exec()")}} 或者 {{jsxref("String.prototype.matchAll()", " String.prototype.matchAll()")}}</li> </ul> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_match" name="Example:_Using_match">例子:使用 <code>match</code></h3> +<h3 id="Example_Using_match">例子:使用 <code>match</code></h3> <p>在下例中,使用 <code>match</code> 查找 "<code>Chapter</code>" 紧跟着 1 个或多个数值字符,再紧跟着一个小数点和数值字符 0 次或多次。正则表达式包含 <code>i</code> 标志,因此大小写会被忽略。</p> @@ -78,7 +78,7 @@ console.log(found); // 'index' 属性(22) 是整个匹配从零开始的索引。 // 'input' 属性是被解析的原始字符串。</pre> -<h3 id="Example_Using_global_and_ignore_case_flags_with_match" name="Example:_Using_global_and_ignore_case_flags_with_match">例子:<code>match</code> 使用全局(global)和忽略大小写(ignore case)标志</h3> +<h3 id="Example_Using_global_and_ignore_case_flags_with_match">例子:<code>match</code> 使用全局(global)和忽略大小写(ignore case)标志</h3> <p>下例展示了 <code>match</code> 使用 global 和 ignore case 标志。A-E、a-e 的所有字母将会作为一个数组的元素返回。</p> @@ -204,7 +204,7 @@ str3.match(null); // 返回["null"]</pre> <li>从 Gecko 49 {{geckoRelease(49)}} 开始 , 不再支持非标准的标志参数 ({{bug(1108382)}}).</li> </ul> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("RegExp")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html index e412b0da5c..45ea5be584 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/repeat/index.html @@ -18,11 +18,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat <p><strong><code>repeat()</code></strong> 构造并返回一个新字符串,该字符串包含被连接在一起的指定数量的字符串的副本。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>str</var>.repeat(<var>count</var>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>count</code></dt> @@ -86,7 +86,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat }</pre> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush:js">"abc".repeat(-1) // RangeError: repeat count must be positive and less than inifinity "abc".repeat(0) // "" @@ -113,7 +113,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <p>{{Compat("javascript.builtins.String.repeat")}}</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/replace/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/replace/index.html index e5930019f1..5e75b81d05 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/replace/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/replace/index.html @@ -145,7 +145,7 @@ var newString = 'abc12345#$*%'.replace(/([^\d]*)(\d*)([^\w]*)/, replacer); console.log(newString); // abc - 12345 - #$*% </pre> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="在_replace_中使用正则表达式">在 <code>replace()</code> 中使用正则表达式</h3> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/slice/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/slice/index.html index b64952f80e..29e58c07a8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/slice/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/slice/index.html @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/slice <p>例 2:<code>str.slice(2, -1)</code> 提取第三个字符到倒数第一个字符。</p> -<h2 id="Examples" name="Examples">例子</h2> +<h2 id="Examples">例子</h2> <h3 id="使用_slice()_创建一个新的字符串">使用 <code>slice()</code> 创建一个新的字符串</h3> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/split/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/split/index.html index c1dee44c87..75ba2c0748 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/split/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/split/index.html @@ -18,7 +18,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/split -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>str.split([separator[, limit]])</em></code> </pre> @@ -40,7 +40,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/split <p>返回源字符串以分隔符出现位置分隔而成的一个 {{jsxref("Array")}} </p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>找到分隔符后,将其从字符串中删除,并将子字符串的数组返回。如果没有找到或者省略了分隔符,则该数组包含一个由整个字符串组成的元素。如果分隔符为空字符串,则将str转换为字符数组。如果分隔符出现在字符串的开始或结尾,或两者都分开,分别以空字符串开头,结尾或两者开始和结束。因此,如果字符串仅由一个分隔符实例组成,则该数组由两个空字符串组成。</p> @@ -48,9 +48,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/split <p>{{Note("当字符串为空时,split()返回一个包含一个空字符串的数组,而不是一个空数组,如果字符串和分隔符都是空字符串,则返回一个空数组。")}}</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_split" name="Example:_Using_split">使用 <code>split()</code></h3> +<h3 id="Example_Using_split">使用 <code>split()</code></h3> <p>下例定义了一个函数:根据指定的分隔符将一个字符串分割成一个字符串数组。分隔字符串后,该函数依次输出原始字符串信息,被使用的分隔符,返回数组元素的个数,以及返回数组中所有的元素。</p> @@ -91,7 +91,7 @@ The separator is: "," The array has 12 elements: Jan / Feb / Mar / Apr / May / Jun / Jul / Aug / Sep / Oct / Nov / Dec / </pre> -<h3 id="Example_Removing_spaces_from_a_string" name="Example:_Removing_spaces_from_a_string">移出字符串中的空格</h3> +<h3 id="Example_Removing_spaces_from_a_string">移出字符串中的空格</h3> <p>下例中,<code>split()</code> 方法会查找“0 或多个空白符接着的分号,再接着 0 或多个空白符”模式的字符串,找到后,就将空白符从字符串中移除,<code>nameList</code> 是 <code>split</code> 的返回数组。</p> @@ -111,7 +111,7 @@ console.log(nameList); [ "Harry Trump", "Fred Barney", "Helen Rigby", "Bill Abel", "Chris Hand", "" ]</code> </pre> -<h3 id="Example_Returning_a_limited_number_of_splits" name="Example:_Returning_a_limited_number_of_splits">限制返回值中分割元素数量</h3> +<h3 id="Example_Returning_a_limited_number_of_splits">限制返回值中分割元素数量</h3> <p>下例中,<code>split</code> 查找字符串中的 0 或多个空格,并返回找到的前 3 个分割元素(splits)。</p> @@ -125,7 +125,7 @@ console.log(splits); <pre><code>["Hello", "World.", "How"]</code></pre> -<h3 id="Example_Capturing_parentheses" name="Example:_Capturing_parentheses">靠正则来分割使结果中包含分隔块</h3> +<h3 id="Example_Capturing_parentheses">靠正则来分割使结果中包含分隔块</h3> <p>如果 <code>separator</code> 包含捕获括号(capturing parentheses),则其匹配结果将会包含在返回的数组中。</p> @@ -203,7 +203,7 @@ const strReverse = str.split(/(?:)/u).reverse().join(''); <p>{{Compat("javascript.builtins.String.split")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("String.prototype.charAt()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/substr/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/substr/index.html index 2fb5de2276..a21f6f1f87 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/substr/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/substr/index.html @@ -11,11 +11,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substr <p><code><strong>substr()</strong></code> 方法返回一个字符串中从指定位置开始到指定字符数的字符。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>str</em>.substr(<em>start</em>[, <em>length</em>])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>start</code></dt> @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substr <dd>可选。提取的字符数。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>start</code> 是一个字符的索引。首字符的索引为 0,最后一个字符的索引为 字符串的长度减去1。<code>substr</code> 从 <code>start</code> 位置开始提取字符,提取 <code>length</code> 个字符(或直到字符串的末尾)。</p> @@ -39,7 +39,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substr <h2 id="示例">示例</h2> -<h3 id="Example:_Using_substr" name="Example:_Using_substr">例子:使用 <code>substr</code></h3> +<h3 id="Example:_Using_substr">例子:使用 <code>substr</code></h3> <pre class="brush: js">var str = "abcdefghij"; @@ -51,7 +51,7 @@ console.log("(-20, 2): " + str.substr(-20,2)); // (-20, 2): ab console.log("(20, 2): " + str.substr(20,2)); // (20, 2): </pre> -<h2 id="Description" name="Description">兼容旧环境(Polyfill)</h2> +<h2 id="Description">兼容旧环境(Polyfill)</h2> <p>Microsoft's JScript 不支持负的 start 索引。如果你想充分利用该方法的功能,则需要使用下面的兼容性代码修复此 bug:</p> @@ -158,7 +158,7 @@ if ('ab'.substr(-1) != 'b') <p><strong>Note</strong>: Up to version 3.6, Firefox had a bug which caused <code>substr</code> to return empty result when an explicit <code>undefined</code> value was passed in as the <code>length</code>.</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("String.prototype.slice()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/substring/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/substring/index.html index 445b0dfea5..6aef7ea138 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/substring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/substring/index.html @@ -9,11 +9,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substring <p><strong><code>substring() </code></strong>方法返回一个字符串在开始索引到结束索引之间的一个子集, 或从开始索引直到字符串的末尾的一个子集。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>str</var>.substring(<var>indexStart</var>[, <var>indexEnd</var>])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>indexStart</code></dt> @@ -26,7 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substring <p>包含给定字符串的指定部分的新字符串。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>substring</code> 提取从 <code>indexStart</code> 到 <code>indexEnd</code>(不包括)之间的字符。特别地:</p> @@ -38,9 +38,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substring <li>如果 <code>indexStart</code> 大于 <code>indexEnd</code>,则 <code>substring</code> 的执行效果就像两个参数调换了一样。见下面的例子。</li> </ul> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_substring" name="Example:_Using_substring">例子:使用 <code>substring</code></h3> +<h3 id="Example_Using_substring">例子:使用 <code>substring</code></h3> <p>下例使用 <code>substring</code> 输出字符串 "<code>Mozilla</code>" 中的字符:</p> @@ -83,7 +83,7 @@ var anyString = 'Mozilla'; var anyString5 = anyString.substring(anyString.length - 5); console.log(anyString5);</pre> -<h3 id="Example_Replacing_a_substring_within_a_string" name="Example:_Replacing_a_substring_within_a_string">例子:替换一个字符串的子字符串</h3> +<h3 id="Example_Replacing_a_substring_within_a_string">例子:替换一个字符串的子字符串</h3> <p>下例替换了一个字符串中的子字符串。可以替换单个字符和子字符串。该例结尾调用的函数将 "<code>Brave New World</code>" 变成了 "<code>Brave New Web</code>"。</p> @@ -186,7 +186,7 @@ replaceString("World", "Web", "Brave New World");</pre> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("String.prototype.substr()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/tostring/index.html index f8f9d021da..ff09cb22b0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/tostring/index.html @@ -5,11 +5,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/toString --- <div>{{JSRef("Global_Objects", "String")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>toString()</strong></code> 方法返回指定对象的字符串形式。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>str</em>.toString()</code> </pre> @@ -18,13 +18,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/toString <p>一个表示调用对象的字符串。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>String</code> 对象覆盖了{{jsxref("Global_Objects/Object", "Object")}} 对象的 <code>toString</code> 方法;并没有继承 {{jsxref("Object.toString()")}}。对于 <code>String</code> 对象,<code>toString</code> 方法返回该对象的字符串形式,和 {{jsxref("String.prototype.valueOf()")}} 方法返回值一样。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example_Using_toString" name="Example:_Using_toString">例子:使用 <code>toString</code></h3> +<h3 id="Example_Using_toString">例子:使用 <code>toString</code></h3> <p>下例输出一个字符串对象(String object)的字符串值:</p> @@ -116,7 +116,7 @@ alert(x.toString()) // 输出 "Hello world"</pre> </table> </div> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.toSource()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/trimend/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/trimend/index.html index a3422659aa..1edf0d9200 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/trimend/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/trimend/index.html @@ -17,7 +17,7 @@ original_slug: Web/JavaScript/Reference/Global_Objects/String/TrimRight <p>The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a href="https://github.com/mdn/interactive-examples">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><var>str</var>.trimEnd(); <var>str</var>.trimRight();</code></pre> @@ -26,7 +26,7 @@ original_slug: Web/JavaScript/Reference/Global_Objects/String/TrimRight <p>一个新字符串,表示从调用字串的末(右)端除去空白。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>trimEnd()</code> / <code>trimRight()</code>方法移除原字符串右端的连续空白符并返回,<code>trimEnd()</code> / <code>trimRight()</code>方法并不会直接修改原字符串本身。</p> @@ -37,7 +37,7 @@ original_slug: Web/JavaScript/Reference/Global_Objects/String/TrimRight <pre class="brush: js"><code>String.prototype.trimRight.name === "trimEnd";</code> </pre> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <h3 id="使用trimEnd">使用<code>trimEnd()</code></h3> @@ -77,7 +77,7 @@ console.log(str); // ' foo' <p>{{Compat("javascript.builtins.String.trimEnd")}}</p> -<h2 id="See_also" name="See_also">相关链接</h2> +<h2 id="See_also">相关链接</h2> <ul> <li>{{jsxref("String.prototype.trim()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/for/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/for/index.html index e0cf9c8bd0..2b5df3a89c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/for/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/for/index.html @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/for <p><code><strong>Symbol.for(key)</strong></code> 方法会根据给定的键 <code>key</code>,来从运行时的 symbol 注册表中找到对应的 symbol,如果找到了,则返回它,否则,新建一个与该键关联的 symbol,并放入全局 symbol 注册表中。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>Symbol.for(key)</var>;</pre> @@ -26,7 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/for <p>返回由给定的 key 找到的 symbol,否则就是返回新创建的 symbol。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>和 <code>Symbol()</code> 不同的是,用 <code>Symbol.for()</code> 方法创建的的 symbol 会被放入一个全局 symbol 注册表中。<code>Symbol.for() 并不是每次都会创建一个新的 symbol</code>,它会首先检查给定的 key 是否已经在注册表中了。假如是,则会直接返回上次存储的那个。否则,它会再新建一个。</p> @@ -147,7 +147,7 @@ Symbol.for("mdn.bar"); </table> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Symbol.keyFor()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/index.html index 38506cf5f0..b44db6a349 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/index.html @@ -17,18 +17,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>Symbol(<em>[description]</em>)</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>description</code> {{optional_inline}}</dt> <dd>可选的,字符串类型。对symbol的描述,可用于调试但不是访问symbol本身。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>直接使用<code>Symbol()</code>创建新的symbol类型,并用一个可选的字符串作为其描述。</p> @@ -62,7 +62,7 @@ typeof symObj; // "object"</pre> <p>{{jsxref("Object.getOwnPropertySymbols()")}} 方法让你在查找一个给定对象的符号属性时返回一个symbol类型的数组。注意,每个初始化的对象都是没有自己的symbol属性的,因此这个数组可能为空,除非你已经在对象上设置了symbol属性。</p> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt><code>Symbol.length</code></dt> @@ -111,7 +111,7 @@ typeof symObj; // "object"</pre> <dd>用于对象的默认描述的字符串值。被 {{jsxref("Object.prototype.toString()")}} 使用。</dd> </dl> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <dl> <dt>{{jsxref("Symbol.for()", "Symbol.for(key)")}}</dt> @@ -120,7 +120,7 @@ typeof symObj; // "object"</pre> <dd>从全局symbol注册表中,为给定的symbol检索一个共享的?symbol key。</dd> </dl> -<h2 id="Boolean_instances" name="Boolean_instances">Symbol 原型</h2> +<h2 id="Boolean_instances">Symbol 原型</h2> <p>所有 Symbols 继承自 {{jsxref("Symbol.prototype")}}.</p> @@ -144,9 +144,9 @@ typeof symObj; // "object"</pre> <dd>返回该 Symbol 对象。</dd> </dl> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Creating_Boolean_objects_with_an_initial_value_of_false" name="Creating_Boolean_objects_with_an_initial_value_of_false">对 symbol 使用 typeof 运算符</h3> +<h3 id="Creating_Boolean_objects_with_an_initial_value_of_false">对 symbol 使用 typeof 运算符</h3> <p> {{jsxref("Operators/typeof", "typeof")}}运算符能帮助你识别 symbol 类型</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/keyfor/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/keyfor/index.html index f42776146b..9877b68ce0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/keyfor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/keyfor/index.html @@ -5,11 +5,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/keyFor --- <div>{{JSRef("Global_Objects", "Symbol")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>Symbol.keyFor(sym)</strong></code> 方法用来获取全局symbol 注册表中与某个 symbol 关联的键。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>Symbol.keyFor(sym)</var>;</pre> @@ -108,7 +108,7 @@ Symbol.keyFor(Symbol.iterator) // undefined </table> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Symbol.prototype.for()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/tostring/index.html index 44be848f73..d59863f878 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/tostring/index.html @@ -5,15 +5,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/toString --- <div>{{JSRef("Global_Objects", "Symbol")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>toString()</strong></code> 方法返回当前 symbol 对象的字符串表示。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>symbol.toString()</var>;</pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>{{jsxref("Symbol")}} 对象拥有自己的 <code>toString</code> 方法,因而遮蔽了原型链上的 {{jsxref("Object.prototype.toString()")}}。</p> @@ -109,7 +109,7 @@ Symbol.for("foo").toString() // "Symbol(foo)" </table> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.toString()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/valueof/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/valueof/index.html index 9185610400..c9e9c55adb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/valueof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/valueof/index.html @@ -5,16 +5,16 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/valueOf --- <div>{{JSRef("Global_Objects", "Symbol")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>valueOf()</strong></code> 方法返回当前 symbol 对象所包含的 symbol 原始值。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><var>symbol.valueOf(); </var></pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>在 JavaScript 中,虽然大多数类型的对象在某些操作下都会自动的隐式调用自身的 <code>valueOf()</code> 方法或者 <code>toString()</code> 方法来将自己转换成一个原始值,但 symbol 对象不会这么干,symbol 对象无法隐式转换成对应的原始值:</p> @@ -99,7 +99,7 @@ Object(Symbol("foo")).toString() + "bar"; </table> </div> -<h2 id="See_Also" name="See_Also">相关链接</h2> +<h2 id="See_Also">相关链接</h2> <ul> <li>{{jsxref("Object.prototype.valueOf()")}}</li> diff --git a/files/zh-cn/web/javascript/reference/global_objects/syntaxerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/syntaxerror/index.html index bdbd1ed86c..6c75432980 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/syntaxerror/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/syntaxerror/index.html @@ -12,15 +12,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError <p><code><strong>SyntaxError</strong></code> 对象代表尝试解析语法上不合法的代码的错误。</p> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>当Javascript语言解析代码时,Javascript引擎发现了不符合语法规范的tokens或token顺序时抛出<code>SyntaxError</code>.</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>new SyntaxError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>message</code></dt> @@ -31,30 +31,30 @@ translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError <dd>可选的. 包含引发异常的代码的行号</dd> </dl> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt>{{jsxref("SyntaxError.prototype")}}</dt> <dd><code>允许SyntaxError</code>对象添加属性.</dd> </dl> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <p>全局 <code>SyntaxError</code> 自身不包含任何方法, 但从原型链中继承了一些方法.</p> -<h2 id="SyntaxError_instances" name="SyntaxError_instances"><code>SyntaxError</code> 实例</h2> +<h2 id="SyntaxError_instances"><code>SyntaxError</code> 实例</h2> -<h3 id="Properties_of_SyntaxError_instances" name="Properties_of_SyntaxError_instances">属性</h3> +<h3 id="Properties_of_SyntaxError_instances">属性</h3> <div>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError/prototype', '属性')}}</div> -<h3 id="Methods_of_SyntaxError_instances" name="Methods_of_SyntaxError_instances">方法</h3> +<h3 id="Methods_of_SyntaxError_instances">方法</h3> <div>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError/prototype', '方法')}}</div> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Catch_an_SyntaxError" name="Example:_Catch_an_SyntaxError">捕获 <code>SyntaxError</code></h3> +<h3 id="Example:_Catch_an_SyntaxError">捕获 <code>SyntaxError</code></h3> <pre class="brush: js">try { eval('hoo bar'); @@ -69,7 +69,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError } </pre> -<h3 id="Example:_Create_an_SyntaxError" name="Example:_Create_an_SyntaxError">创建 <code>SyntaxError</code></h3> +<h3 id="Example:_Create_an_SyntaxError">创建 <code>SyntaxError</code></h3> <pre class="brush: js">try { throw new SyntaxError('Hello', 'someFile.js', 10); diff --git a/files/zh-cn/web/javascript/reference/global_objects/typeerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/typeerror/index.html index b6feb266b3..ce85a5f202 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typeerror/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typeerror/index.html @@ -16,11 +16,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypeError <p><code><strong>TypeError(类型错误)</strong></code> 对象用来表示值的类型非预期类型时发生的错误。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>new TypeError([<var>message</var>[, <var>fileName</var>[, <var>lineNumber</var>]]])</code></pre> -<h3 id="Parameters" name="Parameters">参数</h3> +<h3 id="Parameters">参数</h3> <dl> <dt><code>message 消息</code></dt> @@ -31,34 +31,34 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypeError <dd>可选. 引起该异常的代码的行号。</dd> </dl> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p>当传入函数的<strong>操作数</strong>或<strong>参数</strong>的类型并非操作符或函数所预期的类型时,将抛出一个 TypeError 类型错误。</p> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt>{{jsxref("TypeError.prototype")}}</dt> <dd>允许为一个 TypeError 类型错误附加属性。</dd> </dl> -<h2 id="Methods" name="Methods">方法</h2> +<h2 id="Methods">方法</h2> <p>全局 TypeError 不包含任何方法,不过,它将从原型链中继承一些方法。</p> -<h2 id="TypeError_instances" name="TypeError_instances"><code>TypeError</code> 类型错误实例</h2> +<h2 id="TypeError_instances"><code>TypeError</code> 类型错误实例</h2> -<h3 id="Properties_of_TypeError_instances" name="Properties_of_TypeError_instances">属性</h3> +<h3 id="Properties_of_TypeError_instances">属性</h3> <div>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypeError/prototype', '属性')}}</div> -<h3 id="Methods_of_TypeError_instances" name="Methods_of_TypeError_instances">方法</h3> +<h3 id="Methods_of_TypeError_instances">方法</h3> <div>{{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypeError/prototype', '方法')}}</div> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> -<h3 id="Example:_Catch_an_TypeError" name="Example:_Catch_an_TypeError">示例: 捕获类型错误</h3> +<h3 id="Example:_Catch_an_TypeError">示例: 捕获类型错误</h3> <pre class="brush: js">try { null.f(); @@ -73,7 +73,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypeError } </pre> -<h3 id="Example:_Create_an_TypeError" name="Example:_Create_an_TypeError">示例: 创建一个类型错误</h3> +<h3 id="Example:_Create_an_TypeError">示例: 创建一个类型错误</h3> <pre class="brush: js">try { throw new TypeError('Hello', "someFile.js", 10); diff --git a/files/zh-cn/web/javascript/reference/global_objects/uint32array/index.html b/files/zh-cn/web/javascript/reference/global_objects/uint32array/index.html index 4e8b04116a..bc39c4a39c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/uint32array/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/uint32array/index.html @@ -41,7 +41,7 @@ new Uint32Array(buffer [, byteOffset [, length]]);</pre> <dd>从可变长度的参数创建一个新的 <code>Uint32Array</code> 。请参考 {{jsxref("Array.of()")}}.</dd> </dl> -<h2 id="Boolean_instances" name="Boolean_instances"><code>Uint32Array</code> 原型</h2> +<h2 id="Boolean_instances"><code>Uint32Array</code> 原型</h2> <p>所有 <code>Uint32Array</code> 对象继承自 {{jsxref("TypedArray.prototype", "%TypedArray%.prototype")}}.</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/uint8array/index.html b/files/zh-cn/web/javascript/reference/global_objects/uint8array/index.html index 42345aaf89..1613c9582b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/uint8array/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/uint8array/index.html @@ -39,7 +39,7 @@ new Uint8Array(buffer [, byteOffset [, length]]);</pre> <dd>通过一个可变数目的参数创建一个新的<code>Uint8Array</code>数组,可参见{{jsxref("Array.of()")}}.</dd> </dl> -<h2 id="Boolean_instances" name="Boolean_instances"><code>Uint8Array</code> 原型声明</h2> +<h2 id="Boolean_instances"><code>Uint8Array</code> 原型声明</h2> <p>所有的<code>Uint8Array对象继承自</code> {{jsxref("TypedArray.prototype", "%TypedArray%.prototype")}}.</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/undefined/index.html b/files/zh-cn/web/javascript/reference/global_objects/undefined/index.html index 2748581673..e440e136f6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/undefined/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/undefined/index.html @@ -21,11 +21,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/undefined </div> </div> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code>undefined </code></pre> -<h2 id="Description" name="Description">描述</h2> +<h2 id="Description">描述</h2> <p><code>undefined</code>是<em>全局对象</em>的一个属性。也就是说,它是全局作用域的一个变量。<code>undefined</code>的最初值就是原始数据类型<code>{{Glossary("Undefined", "undefined")}}</code>。</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakmap/delete/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakmap/delete/index.html index b172fc0698..212911cf30 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakmap/delete/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/weakmap/delete/index.html @@ -5,11 +5,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/delete --- <div>{{JSRef("Global_Objects", "WeakMap")}}</div> -<h2 id="Summary" name="Summary">概述</h2> +<h2 id="Summary">概述</h2> <p><code><strong>delete()</strong></code> 方法可以从一个 <code>WeakMap</code> 对象中删除指定的元素。</p> -<h2 id="Syntax" name="Syntax">语法</h2> +<h2 id="Syntax">语法</h2> <pre class="syntaxbox"><code><em>wm</em>.delete(key);</code></pre> @@ -24,7 +24,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/delete <p>如果成功删除,返回 <code>true</code>,否则返回 <code>false</code>。</p> -<h2 id="Examples" name="Examples">示例</h2> +<h2 id="Examples">示例</h2> <pre class="brush: js;">var wm = new WeakMap(); wm.set(window, "foo"); diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakset/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakset/index.html index 1e82a11d54..acfc0a3edf 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakset/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/weakset/index.html @@ -88,7 +88,7 @@ execRecursively(obj => console.log(obj), foo);</pre> <p>在此,在第一次运行时创建<code>WeakSet</code>,并将其与每个后续函数调用一起传递(使用内部参数_refs)。 对象的数量或它们的遍历顺序无关紧要,因此,WeakSet比{{jsxref("Set")}}更适合(和执行)跟踪对象引用,尤其是在涉及大量对象时。</p> -<h2 id="Properties" name="Properties">属性</h2> +<h2 id="Properties">属性</h2> <dl> <dt><code>WeakSet.length</code></dt> @@ -97,7 +97,7 @@ execRecursively(obj => console.log(obj), foo);</pre> <dd>表示<code>WeakSet</code>构造函数的原型。 允许向所有<code>WeakSet</code>对象添加属性。</dd> </dl> -<h2 id="Boolean_instances" name="Boolean_instances"><code>WeakSet</code> 实例</h2> +<h2 id="Boolean_instances"><code>WeakSet</code> 实例</h2> <p>所有 <code>WeakSet</code> 实例都继承自 {{jsxref("WeakSet.prototype")}}.</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compile/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compile/index.html index 6489b54a09..9d98ced5e8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compile/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compile/index.html @@ -84,7 +84,7 @@ onmessage = function(e) { </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2> +<h2 id="Browser_compatibility">Browser compatibility</h2> <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html index 9292349082..99d92ca48d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compileerror/index.html @@ -94,7 +94,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/CompileError </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html index f36e646699..7174637482 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/compilestreaming/index.html @@ -60,7 +60,7 @@ WebAssembly.compileStreaming(fetch('simple.wasm')) </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2> +<h2 id="Browser_compatibility">Browser compatibility</h2> <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/global/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/global/index.html index d8577bae83..c87d989111 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/global/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/global/index.html @@ -89,7 +89,7 @@ WebAssembly.instantiateStreaming(fetch('global.wasm'), { js: { global } }) </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility" <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html index 5ce3af745f..d4b5877590 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/index.html @@ -89,7 +89,7 @@ WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject) </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/instance/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instance/index.html index f7492e2b40..e64f663b93 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/instance/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instance/index.html @@ -63,7 +63,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility" <div>{{Compat("javascript.builtins.WebAssembly.Instance")}}</div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiate/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiate/index.html index 5567c99432..43b3aad734 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiate/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiate/index.html @@ -158,7 +158,7 @@ onmessage = function(e) { </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility" <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html index f6698d9862..15af74d96b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/instantiatestreaming/index.html @@ -66,7 +66,7 @@ WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject) </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2> +<h2 id="Browser_compatibility" <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/memory/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/memory/index.html index 1d559210a4..f8319d669c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/memory/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/memory/index.html @@ -95,7 +95,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility" <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html index 9132ef1e4f..5f3839d6b2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/module/index.html @@ -70,7 +70,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> <p>{{Compat("javascript.builtins.WebAssembly.Module")}}</p> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html index 3962917a9e..7d0598d250 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/runtimeerror/index.html @@ -94,7 +94,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/RuntimeError </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/table/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/table/index.html index 9be0f967cd..5e1b468f38 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/table/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/table/index.html @@ -113,7 +113,7 @@ console.log(tbl.get(1)); // "null"</pre> </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">浏览器兼容性</h2> +<h2 id="Browser_compatibility">浏览器兼容性</h2> <div> diff --git a/files/zh-cn/web/javascript/reference/global_objects/webassembly/validate/index.html b/files/zh-cn/web/javascript/reference/global_objects/webassembly/validate/index.html index 7d44cc216b..0570071ca1 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/webassembly/validate/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/webassembly/validate/index.html @@ -58,7 +58,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/validate </tbody> </table> -<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2> +<h2 id="Browser_compatibility">Browser compatibility</h2> <div> |