diff options
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/number')
17 files changed, 85 insertions, 85 deletions
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> |