From c40612041809fe289aba58aefa170bbe784aba1f Mon Sep 17 00:00:00 2001 From: t7yang Date: Mon, 10 Jan 2022 08:38:07 +0800 Subject: remove name attribute for zh-CN --- .../global_objects/array/concat/index.html | 12 ++++---- .../global_objects/array/copywithin/index.html | 2 +- .../reference/global_objects/array/fill/index.html | 8 +++--- .../reference/global_objects/array/find/index.html | 10 +++---- .../global_objects/array/findindex/index.html | 12 ++++---- .../global_objects/array/indexof/index.html | 4 +-- .../reference/global_objects/array/join/index.html | 16 +++++------ .../reference/global_objects/array/keys/index.html | 10 +++---- .../global_objects/array/lastindexof/index.html | 18 ++++++------ .../global_objects/array/length/index.html | 8 +++--- .../reference/global_objects/array/map/index.html | 16 +++++------ .../reference/global_objects/array/of/index.html | 6 ++-- .../reference/global_objects/array/pop/index.html | 8 +++--- .../reference/global_objects/array/push/index.html | 2 +- .../global_objects/array/reverse/index.html | 2 +- .../global_objects/array/slice/index.html | 6 ++-- .../reference/global_objects/array/some/index.html | 14 +++++----- .../reference/global_objects/array/sort/index.html | 16 +++++------ .../global_objects/array/tolocalestring/index.html | 4 +-- .../global_objects/array/tosource/index.html | 14 +++++----- .../global_objects/array/tostring/index.html | 6 ++-- .../global_objects/array/unshift/index.html | 6 ++-- .../global_objects/boolean/tostring/index.html | 6 ++-- .../global_objects/boolean/valueof/index.html | 10 +++---- .../global_objects/date/getdate/index.html | 12 ++++---- .../global_objects/date/getday/index.html | 10 +++---- .../global_objects/date/getfullyear/index.html | 10 +++---- .../global_objects/date/gethours/index.html | 10 +++---- .../global_objects/date/getmilliseconds/index.html | 12 ++++---- .../global_objects/date/getminutes/index.html | 12 ++++---- .../global_objects/date/getmonth/index.html | 12 ++++---- .../global_objects/date/getseconds/index.html | 12 ++++---- .../global_objects/date/gettime/index.html | 10 +++---- .../date/gettimezoneoffset/index.html | 10 +++---- .../global_objects/date/getutcdate/index.html | 12 ++++---- .../global_objects/date/getutcday/index.html | 12 ++++---- .../global_objects/date/getutcfullyear/index.html | 12 ++++---- .../global_objects/date/getutchours/index.html | 12 ++++---- .../date/getutcmilliseconds/index.html | 12 ++++---- .../global_objects/date/getutcminutes/index.html | 12 ++++---- .../global_objects/date/getutcmonth/index.html | 12 ++++---- .../global_objects/date/getutcseconds/index.html | 12 ++++---- .../global_objects/date/getyear/index.html | 22 +++++++-------- .../reference/global_objects/date/parse/index.html | 16 +++++------ .../global_objects/date/setdate/index.html | 12 ++++---- .../global_objects/date/setfullyear/index.html | 12 ++++---- .../global_objects/date/sethours/index.html | 14 +++++----- .../global_objects/date/setmilliseconds/index.html | 12 ++++---- .../global_objects/date/setminutes/index.html | 14 +++++----- .../global_objects/date/setmonth/index.html | 14 +++++----- .../global_objects/date/setseconds/index.html | 12 ++++---- .../global_objects/date/settime/index.html | 14 +++++----- .../global_objects/date/setutcdate/index.html | 12 ++++---- .../global_objects/date/todatestring/index.html | 10 +++---- .../global_objects/date/togmtstring/index.html | 8 +++--- .../global_objects/date/toisostring/index.html | 6 ++-- .../global_objects/date/tojson/index.html | 8 +++--- .../date/tolocaledatestring/index.html | 18 ++++++------ .../global_objects/date/tolocalestring/index.html | 18 ++++++------ .../date/tolocaletimestring/index.html | 18 ++++++------ .../global_objects/date/tostring/index.html | 12 ++++---- .../global_objects/date/totimestring/index.html | 10 +++---- .../global_objects/date/toutcstring/index.html | 12 ++++---- .../reference/global_objects/date/utc/index.html | 12 ++++---- .../global_objects/date/valueof/index.html | 12 ++++---- .../reference/global_objects/error/index.html | 22 +++++++-------- .../global_objects/error/message/index.html | 10 +++---- .../reference/global_objects/error/name/index.html | 10 +++---- .../global_objects/error/tostring/index.html | 10 +++---- .../reference/global_objects/escape/index.html | 10 +++---- .../reference/global_objects/eval/index.html | 2 +- .../reference/global_objects/evalerror/index.html | 8 +++--- .../global_objects/float32array/index.html | 2 +- .../global_objects/function/apply/index.html | 14 +++++----- .../global_objects/function/call/index.html | 2 +- .../global_objects/function/caller/index.html | 10 +++---- .../global_objects/function/length/index.html | 4 +-- .../global_objects/function/tosource/index.html | 10 +++---- .../global_objects/function/tostring/index.html | 6 ++-- .../reference/global_objects/generator/index.html | 2 +- .../global_objects/generator/next/index.html | 12 ++++---- .../global_objects/generator/return/index.html | 12 ++++---- .../global_objects/generator/throw/index.html | 10 +++---- .../global_objects/generatorfunction/index.html | 14 +++++----- .../reference/global_objects/infinity/index.html | 2 +- .../reference/global_objects/isfinite/index.html | 8 +++--- .../reference/global_objects/isnan/index.html | 12 ++++---- .../reference/global_objects/json/index.html | 14 +++++----- .../global_objects/json/stringify/index.html | 4 +-- .../reference/global_objects/math/abs/index.html | 12 ++++---- .../reference/global_objects/math/acos/index.html | 14 +++++----- .../reference/global_objects/math/asin/index.html | 14 +++++----- .../reference/global_objects/math/atan/index.html | 14 +++++----- .../reference/global_objects/math/atan2/index.html | 14 +++++----- .../reference/global_objects/math/cbrt/index.html | 10 +++---- .../reference/global_objects/math/clz32/index.html | 12 ++++---- .../reference/global_objects/math/cos/index.html | 14 +++++----- .../reference/global_objects/math/e/index.html | 10 +++---- .../reference/global_objects/math/exp/index.html | 14 +++++----- .../reference/global_objects/math/expm1/index.html | 12 ++++---- .../reference/global_objects/math/floor/index.html | 14 +++++----- .../global_objects/math/fround/index.html | 20 +++++++------- .../reference/global_objects/math/hypot/index.html | 8 +++--- .../reference/global_objects/math/imul/index.html | 2 +- .../reference/global_objects/math/ln10/index.html | 10 +++---- .../reference/global_objects/math/ln2/index.html | 10 +++---- .../reference/global_objects/math/log/index.html | 12 ++++---- .../reference/global_objects/math/log10/index.html | 12 ++++---- .../global_objects/math/log10e/index.html | 10 +++---- .../reference/global_objects/math/log1p/index.html | 10 +++---- .../reference/global_objects/math/log2/index.html | 12 ++++---- .../reference/global_objects/math/log2e/index.html | 10 +++---- .../reference/global_objects/math/max/index.html | 12 ++++---- .../reference/global_objects/math/min/index.html | 14 +++++----- .../reference/global_objects/math/pi/index.html | 10 +++---- .../reference/global_objects/math/pow/index.html | 12 ++++---- .../global_objects/math/random/index.html | 6 ++-- .../reference/global_objects/math/round/index.html | 12 ++++---- .../reference/global_objects/math/sign/index.html | 12 ++++---- .../reference/global_objects/math/sin/index.html | 14 +++++----- .../reference/global_objects/math/sinh/index.html | 12 ++++---- .../reference/global_objects/math/sqrt/index.html | 10 +++---- .../global_objects/math/sqrt1_2/index.html | 10 +++---- .../reference/global_objects/math/sqrt2/index.html | 10 +++---- .../reference/global_objects/math/tan/index.html | 12 ++++---- .../reference/global_objects/math/trunc/index.html | 8 +++--- .../reference/global_objects/nan/index.html | 4 +-- .../reference/global_objects/number/index.html | 24 ++++++++-------- .../global_objects/number/isfinite/index.html | 8 +++--- .../global_objects/number/isinteger/index.html | 14 +++++----- .../global_objects/number/issafeinteger/index.html | 8 +++--- .../global_objects/number/max_value/index.html | 10 +++---- .../global_objects/number/min_value/index.html | 10 +++---- .../reference/global_objects/number/nan/index.html | 4 +-- .../number/negative_infinity/index.html | 8 +++--- .../global_objects/number/parsefloat/index.html | 10 +++---- .../global_objects/number/parseint/index.html | 6 ++-- .../number/positive_infinity/index.html | 2 +- .../global_objects/number/toexponential/index.html | 14 +++++----- .../global_objects/number/tofixed/index.html | 10 +++---- .../global_objects/number/toprecision/index.html | 12 ++++---- .../global_objects/number/tosource/index.html | 10 +++---- .../global_objects/number/tostring/index.html | 8 +++--- .../global_objects/number/valueof/index.html | 12 ++++---- .../object/__definegetter__/index.html | 16 +++++------ .../object/__definesetter__/index.html | 14 +++++----- .../object/__lookupgetter__/index.html | 14 +++++----- .../global_objects/object/assign/index.html | 32 +++++++++++----------- .../global_objects/object/constructor/index.html | 8 +++--- .../global_objects/object/create/index.html | 12 ++++---- .../object/defineproperties/index.html | 6 ++-- .../global_objects/object/freeze/index.html | 10 +++---- .../object/getownpropertydescriptor/index.html | 8 +++--- .../object/getownpropertynames/index.html | 8 +++--- .../object/getownpropertysymbols/index.html | 6 ++-- .../object/getprototypeof/index.html | 6 ++-- .../reference/global_objects/object/index.html | 6 ++-- .../global_objects/object/isextensible/index.html | 12 ++++---- .../global_objects/object/isfrozen/index.html | 10 +++---- .../global_objects/object/issealed/index.html | 2 +- .../global_objects/object/keys/index.html | 8 +++--- .../object/preventextensions/index.html | 10 +++---- .../global_objects/object/seal/index.html | 12 ++++---- .../object/setprototypeof/index.html | 10 +++---- .../object/tolocalestring/index.html | 6 ++-- .../global_objects/object/tosource/index.html | 14 +++++----- .../global_objects/object/valueof/index.html | 4 +-- .../reference/global_objects/parsefloat/index.html | 2 +- .../reference/global_objects/parseint/index.html | 2 +- .../global_objects/promise/catch/index.html | 4 +-- .../global_objects/promise/race/index.html | 4 +-- .../global_objects/promise/reject/index.html | 4 +-- .../global_objects/promise/resolve/index.html | 4 +-- .../global_objects/referenceerror/index.html | 26 +++++++++--------- .../global_objects/regexp/exec/index.html | 6 ++-- .../global_objects/regexp/global/index.html | 10 +++---- .../global_objects/regexp/ignorecase/index.html | 10 +++---- .../reference/global_objects/regexp/index.html | 10 +++---- .../global_objects/regexp/lastindex/index.html | 6 ++-- .../global_objects/regexp/multiline/index.html | 10 +++---- .../global_objects/regexp/source/index.html | 10 +++---- .../global_objects/regexp/test/index.html | 10 +++---- .../global_objects/regexp/tosource/index.html | 8 +++--- .../global_objects/regexp/tostring/index.html | 14 +++++----- .../reference/global_objects/set/add/index.html | 4 +-- .../reference/global_objects/set/clear/index.html | 4 +-- .../reference/global_objects/set/delete/index.html | 6 ++-- .../reference/global_objects/set/has/index.html | 8 +++--- .../reference/global_objects/set/index.html | 2 +- .../global_objects/string/anchor/index.html | 2 +- .../global_objects/string/charat/index.html | 14 +++++----- .../global_objects/string/charcodeat/index.html | 4 +-- .../global_objects/string/concat/index.html | 10 +++---- .../global_objects/string/fromcharcode/index.html | 8 +++--- .../global_objects/string/includes/index.html | 4 +-- .../reference/global_objects/string/index.html | 18 ++++++------ .../global_objects/string/indexof/index.html | 2 +- .../global_objects/string/lastindexof/index.html | 12 ++++---- .../global_objects/string/length/index.html | 8 +++--- .../global_objects/string/link/index.html | 2 +- .../global_objects/string/match/index.html | 16 +++++------ .../global_objects/string/repeat/index.html | 8 +++--- .../global_objects/string/replace/index.html | 2 +- .../global_objects/string/slice/index.html | 2 +- .../global_objects/string/split/index.html | 16 +++++------ .../global_objects/string/substr/index.html | 12 ++++---- .../global_objects/string/substring/index.html | 14 +++++----- .../global_objects/string/tostring/index.html | 12 ++++---- .../global_objects/string/trimend/index.html | 8 +++--- .../reference/global_objects/symbol/for/index.html | 6 ++-- .../reference/global_objects/symbol/index.html | 16 +++++------ .../global_objects/symbol/keyfor/index.html | 6 ++-- .../global_objects/symbol/tostring/index.html | 8 +++--- .../global_objects/symbol/valueof/index.html | 8 +++--- .../global_objects/syntaxerror/index.html | 22 +++++++-------- .../reference/global_objects/typeerror/index.html | 22 +++++++-------- .../global_objects/uint32array/index.html | 2 +- .../reference/global_objects/uint8array/index.html | 2 +- .../reference/global_objects/undefined/index.html | 4 +-- .../global_objects/weakmap/delete/index.html | 6 ++-- .../reference/global_objects/weakset/index.html | 4 +-- .../global_objects/webassembly/compile/index.html | 2 +- .../webassembly/compileerror/index.html | 2 +- .../webassembly/compilestreaming/index.html | 2 +- .../global_objects/webassembly/global/index.html | 2 +- .../global_objects/webassembly/index.html | 2 +- .../global_objects/webassembly/instance/index.html | 2 +- .../webassembly/instantiate/index.html | 2 +- .../webassembly/instantiatestreaming/index.html | 2 +- .../global_objects/webassembly/memory/index.html | 2 +- .../global_objects/webassembly/module/index.html | 2 +- .../webassembly/runtimeerror/index.html | 2 +- .../global_objects/webassembly/table/index.html | 2 +- .../global_objects/webassembly/validate/index.html | 2 +- 234 files changed, 1116 insertions(+), 1116 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects') 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
var new_array = old_array.concat(value1[, value2[, ...[, valueN]]])
-

参数

+

参数

valueN{{optional_inline}}
@@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat

新的 {{jsxref("Array")}} 实例。

-

描述

+

描述

concat方法创建一个新的数组,它由被调用的对象中的元素组成,每个参数的顺序依次是该参数的元素(如果参数是数组)或参数本身(如果参数不是数组)。它不会递归到嵌套数组参数中。

@@ -47,9 +47,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat

注意:数组/值在连接时保持不变。此外,对于新数组的任何操作(仅当元素不是对象引用时)都不会对原始数组产生影响,反之亦然。

-

示例

+

示例

-

连接两个数组

+

连接两个数组

以下代码将两个数组合并为一个新数组:

@@ -59,7 +59,7 @@ var numeric = [1, 2, 3]; alpha.concat(numeric); // result in ['a', 'b', 'c', 1, 2, 3] -

连接三个数组

+

连接三个数组

以下代码将三个数组合并为一个新数组:

@@ -72,7 +72,7 @@ var nums = num1.concat(num2, num3); console.log(nums); // results in [1, 2, 3, 4, 5, 6, 7, 8, 9] -

将值连接到数组

+

将值连接到数组

以下代码将三个值连接到数组:

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
arr.copyWithin(target[, start[, end]])
 
-

参数

+

参数

target
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

{{EmbedInteractiveExample("pages/js/array-fill.html")}}

-

语法

+

语法

arr.fill(value[start[end]])
-

参数

+

参数

value
@@ -34,7 +34,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/fill

修改后的数组。

-

描述

+

描述

fill 方法接受三个参数 value, start 以及 endstartend 参数是可选的, 其默认值分别为 0 和 this 对象的 length 属性值。

@@ -145,7 +145,7 @@ arr[0].hi = "hi"; // [{ hi: "hi" }, { hi: "hi" }, { hi: "hi" }] -

相关

+

相关

  • {{jsxref("Array")}}
  • 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

    如果你需要找到一个元素的位置或者一个元素是否存在于数组中,使用{{jsxref("Array.prototype.indexOf()")}} 或 {{jsxref("Array.prototype.includes()")}}。

    -

    语法

    +

    语法

    arr.find(callback[, thisArg])
    -

    参数

    +

    参数

    callback
    @@ -45,7 +45,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/find

    数组中第一个满足所提供测试函数的元素的值,否则返回 {{jsxref("undefined")}}。

    -

    描述

    +

    描述

    find方法对数组中的每一项元素执行一次 callback 函数,直至有一个 callback 返回 true。当找到了这样一个元素后,该方法会立即返回这个元素的值,否则返回 {{jsxref("undefined")}}。注意 callback 函数会为数组中的每个索引调用即从 0 length - 1,而不仅仅是那些被赋值的索引,这意味着对于稀疏数组来说,该方法的效率要低于那些只遍历有值的索引的方法。

    @@ -114,7 +114,7 @@ a.find(function(value, index) { console.log('Visited index ' + index + ' with value ' + value); }); -

    Polyfill

    +

    Polyfill

    本方法在ECMAScript 6规范中被加入,可能不存在于某些实现中。你可以通过以下代码来补充 Array.prototype.find()

    @@ -189,7 +189,7 @@ if (!Array.prototype.find) {

    {{Compat("javascript.builtins.Array.find")}}

    -

    相关链接

    +

    相关链接

    • {{jsxref("Array.prototype.findIndex()")}} – find and return an index
    • 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

      另请参见  {{jsxref("Array.find", "find()")}} 方法,它返回数组中找到的元素的,而不是其索引。

      -

      语法

      +

      语法

      arr.findIndex(callback[, thisArg])
      -

      参数

      +

      参数

      callback
      @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex

          数组中通过提供测试函数的第一个元素的索引。否则,返回-1

      -

      描述

      +

      描述

      findIndex方法对数组中的每个数组索引0..length-1(包括)执行一次callback函数,直到找到一个callback函数返回真实值(强制为true)的值。如果找到这样的元素,findIndex会立即返回该元素的索引。如果回调从不返回真值,或者数组的length为0,则findIndex返回-1。 与某些其他数组方法(如Array#some)不同,在稀疏数组中,即使对于数组中不存在的条目的索引也会调用回调函数。

      @@ -56,9 +56,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/findIndex

      在第一次调用callback函数时会确定元素的索引范围,因此在findIndex方法开始执行之后添加到数组的新元素将不会被callback函数访问到。如果数组中一个尚未被callback函数访问到的元素的值被callback函数所改变,那么当callback函数访问到它时,它的值是将是根据它在数组中的索引所访问到的当前值。被删除的元素仍然会被访问到。

      -

      示例

      +

      示例

      -

      查找数组中首个质数元素的索引

      +

      查找数组中首个质数元素的索引

      以下示例查找数组中素数的元素的索引(如果不存在素数,则返回-1)。

      @@ -153,7 +153,7 @@ if (!Array.prototype.findIndex) {

      {{Compat("javascript.builtins.Array.findIndex")}}

      -

      相关链接

      +

      相关链接

      • {{jsxref("Array.prototype.find()")}}
      • 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

        注意:对于String方法,请参阅 {{jsxref("String.prototype.indexOf()")}}。

        -

        语法

        +

        语法

        arr.indexOf(searchElement[, fromIndex])
        @@ -189,7 +189,7 @@ if (!Array.prototype.indexOf) {

        {{Compat("javascript.builtins.Array.indexOf")}}

        -

        相关链接

        +

        相关链接

        • {{jsxref("Array.prototype.lastIndexOf()")}}
        • 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
          {{EmbedInteractiveExample("pages/js/array-join.html")}}
          -

          语法

          +

          语法

          arr.join([separator])
          -

          参数

          +

          参数

          separator {{optional_inline}}
          @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join
          一个所有数组元素连接的字符串。如果 arr.length 为0,则返回空字符串。
          -

          描述

          +

          描述

          所有的数组元素被转换成字符串,再用一个分隔符将这些字符串连接起来。

          @@ -37,9 +37,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join

          如果一个元素为 undefined 或 null,它会被转换为空字符串。

          -

          示例

          +

          示例

          -

          使用四种不同的分隔符连接数组元素

          +

          使用四种不同的分隔符连接数组元素

          下例首先创建了一个数组 a,包含有三个元素,然后用四种不同的分隔符连接所有数组元素。首先是默认的分隔符逗号,然后是一个逗号加空格,接下来是一个加号前后加空格,最后是一个空字符串。

          @@ -60,7 +60,7 @@ var myVar4 = a.join(''); // myVar4的值变为"WindRainFire" } f(1, 'a', true); -

          规范

          +

          规范

          @@ -92,7 +92,7 @@ f(1, 'a', true);
          -

          浏览器兼容性

          +

          浏览器兼容性

          @@ -102,7 +102,7 @@ f(1, 'a', true);
          -

          相关链接

          +

          相关链接

          • {{jsxref("String.prototype.split()")}}
          • 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
            {{EmbedInteractiveExample("pages/js/array-keys.html")}}
            -

            语法

            +

            语法

            arr.keys()
             
            @@ -25,7 +25,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/keys

            一个新的 {{jsxref("Array")}} 迭代器对象。

            -

            示例

            +

            示例

            索引迭代器会包含那些没有对应元素的索引

            @@ -36,7 +36,7 @@ console.log(sparseKeys); // ['0', '2'] console.log(denseKeys); // [0, 1, 2] -

            规范

            +

            规范

            @@ -58,7 +58,7 @@ console.log(denseKeys); // [0, 1, 2]
            -

            浏览器兼容性

            +

            浏览器兼容性

            @@ -68,7 +68,7 @@ console.log(denseKeys); // [0, 1, 2]
            -

            相关链接

            +

            相关链接

            • {{jsxref("Array.prototype.values()")}}
            • 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 ---
              {{JSRef("Global_Objects", "Array")}}
              -

              概述

              +

              概述

              lastIndexOf() 方法返回指定元素(也即有效的 JavaScript 值或变量)在数组中的最后一个的索引,如果不存在则返回 -1。从数组的后面向前查找,从 fromIndex 处开始。

              {{EmbedInteractiveExample("pages/js/array-lastindexof.html")}}
              -

              语法

              +

              语法

              arr.lastIndexOf(searchElement[, fromIndex])
              -

              参数

              +

              参数

              searchElement
              @@ -29,13 +29,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf
              -

              描述

              +

              描述

              lastIndexOf 使用严格相等(strict equality,即 ===)比较 searchElement 和数组中的元素。

              -

              示例

              +

              示例

              -

              例子:使用 lastIndexOf

              +

              例子:使用 lastIndexOf

              下例使用 lastIndexOf 定位数组中的值。

              @@ -54,7 +54,7 @@ index = array.lastIndexOf(2, -1); // index is 3 -

              例子:查找所有元素

              +

              例子:查找所有元素

              下例使用 lastIndexOf 查找到一个元素在数组中所有的索引(下标),并使用 {{jsxref("Array.push", "push")}} 将所有添加到另一个数组中。

              @@ -80,7 +80,7 @@ console.log(indices); idx > 0时,才进入lastIndexOf由后往前移一位进行倒查找;如果idx == 0则直接设置idx = -1,循环while (idx != -1)就结束了。
               

              -

              兼容旧环境(Polyfill)

              +

              兼容旧环境(Polyfill)

              lastIndexOf 在 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")}} 拥有其初始值。

              @@ -168,7 +168,7 @@ console.log(indices);

              {{Compat("javascript.builtins.Array.lastIndexOf")}}

              -

              相关链接

              +

              相关链接

              • {{jsxref("Array.prototype.indexOf()")}}
              • 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
                {{EmbedInteractiveExample("pages/js/array-length.html")}}
                -

                描述

                +

                描述

                length 属性的值是一个 0 到 232-1 的整数。

                @@ -76,9 +76,9 @@ function printEntries(arr) {
              • Enumerable :如果设置为 true ,属性可以通过迭代器forfor...in进行迭代。
              -

              示例 

              +

              示例 

              -

              遍历数组

              +

              遍历数组

              下面的例子中,通过数组下标遍历数组元素,并把每个元素的值修改为原值的2倍。

              @@ -89,7 +89,7 @@ for (var i = 0; i < length; i++) { } // 遍历后的结果 [2, 4, 6, 8, 10] -

              截断数组

              +

              截断数组

              下面的例子中,如果数组长度大于 3,则把该数组的长度截断为 3 。

              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 -

              语法

              +

              语法

              var new_array = arr.map(function callback(currentValue[, index[, array]]) {
                // Return element for new_array 
               }[, thisArg])
              -

              参数

              +

              参数

              callback
              @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map

              一个由原数组每个元素执行回调函数的结果组成的新数组。

              -

              描述

              +

              描述

              map 方法会给原数组中的每个元素都按顺序调用一次  callback 函数。callback 每次执行后的返回值(包括 {{jsxref("undefined")}})组合起来形成一个新数组。 callback 函数只会在有值的索引上被调用;那些从来没被赋过值或者使用 delete 删除的索引则不会被调用。

              @@ -62,9 +62,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/map

              根据规范中定义的算法,如果被map调用的数组是离散的,新数组将也是离散的保持相同的索引为空。

              -

              示例

              +

              示例

              -

              求数组中每个元素的平方根

              +

              求数组中每个元素的平方根

              下面的代码创建了一个新数组,值为原数组中对应数字的平方根。

              @@ -94,7 +94,7 @@ var reformattedArray = kvArray.map(function(obj) { // {key: 3, value: 30}] -

              使用一个包含一个参数的函数来mapping(构建)一个数字数组

              +

              使用一个包含一个参数的函数来mapping(构建)一个数字数组

              下面的代码表示了当函数需要一个参数时map的工作方式。当map循环遍历原始数组时,这个参数会自动被分配成数组中对应的每个元素。

              @@ -106,7 +106,7 @@ var doubles = numbers.map(function(num) { // doubles数组的值为: [2, 8, 18] // numbers数组未被修改: [1, 4, 9] -

              一般的map 方法

              +

              一般的map 方法

              下面的例子演示如何在一个 {{jsxref("String")}}  上使用 map 方法获取字符串中每个字符所对应的 ASCII 码组成的数组:

              @@ -334,7 +334,7 @@ if (!Array.prototype.map) {

              {{Compat("javascript.builtins.Array.map")}}

              -

              相关链接

              +

              相关链接

              • {{jsxref("Array.prototype.forEach()")}}
              • 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] -

                语法

                +

                语法

                Array.of(element0[, element1[, ...[, elementN]]])
                -

                参数

                +

                参数

                elementN
                @@ -50,7 +50,7 @@ Array.of(1, 2, 3); // [1, 2, 3] Array.of(undefined); // [undefined] -

                兼容旧环境

                +

                兼容旧环境

                如果原生不支持的话,在其他代码之前执行以下代码会创建 Array.of() 。

                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 -

                语法

                +

                语法

                arr.pop()
                @@ -25,7 +25,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/pop

                从数组中删除的元素(当数组为空时返回{{jsxref("undefined")}})。

                -

                描述

                +

                描述

                pop 方法从一个数组中删除并返回最后一个元素。

                @@ -33,9 +33,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/pop

                如果你在一个空数组上调用 pop(),它返回  {{jsxref("undefined")}}。

                -

                示例

                +

                示例

                -

                例子: 删除掉数组的最后一个元素

                +

                例子: 删除掉数组的最后一个元素

                下面的代码首先创建了一个拥有四个元素的数组 myFish,然后删除掉它的最后一个元素。

                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

                当调用该方法时,新的 {{jsxref("Array.length", "length")}} 属性值将被返回。

                -

                描述

                +

                描述

                push方法将值追加到数组中。

                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} -

                相关链接

                +

                相关链接

                • {{jsxref("Array.prototype.join()")}}
                • 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

                  如果向两个数组任一中添加了新元素,则另一个不会受到影响。

                  -

                  示例

                  +

                  示例

                  返回现有数组的一部分

                  @@ -108,7 +108,7 @@ The new color of my Honda is purple newCar[0].color = purple -

                  类数组(Array-like)对象

                  +

                  类数组(Array-like)对象

                  slice 方法可以用来将一个类数组(Array-like)对象/集合转换成一个新数组。你只需将该方法绑定到这个对象上。 一个函数中的  {{jsxref("Functions/arguments", "arguments")}} 就是一个类数组对象的例子。

                  @@ -242,7 +242,7 @@ var list1 = list(1, 2, 3); // [1, 2, 3]

                  {{Compat("javascript.builtins.Array.slice")}}

                  -

                  相关链接

                  +

                  相关链接

                  • {{jsxref("Array.prototype.splice()")}}
                  • 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
                    {{EmbedInteractiveExample("pages/js/array-some.html")}}
                    -

                    语法

                    +

                    语法

                    arr.some(callback(element[, index[, array]])[, thisArg])
                    -

                    参数

                    +

                    参数

                    callback
                    @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some

                    数组中有至少一个元素通过回调函数的测试就会返回true;所有元素都没有通过回调函数的测试返回值才会为false。

                    -

                    描述

                    +

                    描述

                    some() 为数组中的每一个元素执行一次 callback 函数,直到找到一个使得 callback 返回一个“真值”(即可转换为布尔值 true 的值)。如果找到了这样一个值,some() 将会立即返回 true。否则,some() 返回 falsecallback 只会在那些”有值“的索引上被调用,不会在那些被删除或从来未被赋值的索引上调用。

                    @@ -58,9 +58,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some

                    some() 遍历的元素的范围在第一次调用 callback. 前就已经确定了。在调用 some() 后被添加到数组中的值不会被 callback 访问到。如果数组中存在且还未被访问到的元素被 callback 改变了,则其传递给 callback 的值是 some() 访问到它那一刻的值。已经被删除的元素不会被访问到。

                    -

                    示例

                    +

                    示例

                    -

                    测试数组元素的值

                    +

                    测试数组元素的值

                    下面的例子检测在数组中是否有元素大于 10。

                    @@ -127,7 +127,7 @@ getBoolean(1); // true getBoolean('true'); // true -

                    Polyfill

                    +

                    Polyfill

                    在第 5 版时,some() 被添加进 ECMA-262 标准;这样导致某些实现环境可能不支持它。你可以把下面的代码插入到脚本的开头来解决此问题,从而允许在那些没有原生支持它的实现环境中使用它。该算法是 ECMA-262 第 5 版中指定的算法,假定 Object 和 TypeError 拥有他们的初始值,且 fun.call 等价于 {{jsxref("Function.prototype.call")}}

                    @@ -196,7 +196,7 @@ if (!Array.prototype.some) {

                    {{Compat("javascript.builtins.Array.some")}}

                    -

                    相关链接

                    +

                    相关链接

                    • {{jsxref("Array.prototype.find()")}}
                    • 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

                      排序后的数组。请注意,数组已原地排序,并且不进行复制。

                      -

                      描述

                      +

                      描述

                      如果没有指明 compareFunction ,那么元素会按照转换为的字符串的诸个字符的Unicode位点进行排序。例如 "Banana" 会被排列到 "cherry" 之前。当数字按由小到大排序时,9 出现在 80 之前,但因为(没有指明 compareFunction),比较的数字会先被转换为字符串,所以在Unicode顺序上 "80" 要比 "9" 要靠前。

                      @@ -129,9 +129,9 @@ items.sort(function(a, b) { return 0; }); -

                      示例

                      +

                      示例

                      -

                      创建、显示及排序数组

                      +

                      创建、显示及排序数组

                      下述示例创建了四个数组,并展示原数组。之后对数组进行排序。对比了数字数组分别指定与不指定比较函数的结果。

                      @@ -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 -

                      对非 ASCII 字符排序

                      +

                      对非 ASCII 字符排序

                      当排序非 ASCII 字符的字符串(如包含类似 e, é, è, a, ä 等字符的字符串)。一些非英语语言的字符串需要使用 {{jsxref("String.localeCompare")}}。这个函数可以将函数排序到正确的顺序。

                      @@ -191,7 +191,7 @@ items.sort(function (a, b) { // items is ['adieu', 'café', 'cliché', 'communiqué', 'premier', 'réservé'] -

                      使用映射改善排序

                      +

                      使用映射改善排序

                      compareFunction 可能需要对元素做多次映射以实现排序,尤其当 compareFunction 较为复杂,且元素较多的时候,某些 compareFunction 可能会导致很高的负载。使用 map 辅助排序将会是一个好主意。基本思想是首先将数组中的每个元素比较的实际值取出来,排序后再将数组恢复。

                      @@ -253,7 +253,7 @@ var result = mapped.map(function(el){ ]; -

                      规范

                      +

                      规范

                      @@ -285,7 +285,7 @@ var result = mapped.map(function(el){
                      -

                      浏览器兼容性

                      +

                      浏览器兼容性

                      @@ -295,7 +295,7 @@ var result = mapped.map(function(el){
                      -

                      参考

                      +

                      参考

                      • {{jsxref("Array.prototype.reverse()")}}
                      • 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
                        {{EmbedInteractiveExample("pages/js/array-tolocalestring.html")}}
                        -

                        语法

                        +

                        语法

                        arr.toLocaleString([locales[,options]]);
                        @@ -166,7 +166,7 @@ if (!Array.prototype.toLocaleString) {

                        {{Compat("javascript.builtins.Array.toLocaleString")}}

                        -

                        参见

                        +

                        参见

                        • {{jsxref("Array.prototype.toString()")}}
                        • 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 ---

                          {{JSRef("Global_Objects", "Array")}}{{Non-standard_header}}

                          -

                          概述

                          +

                          概述

                          返回一个字符串,代表该数组的源代码.

                          -

                          语法

                          +

                          语法

                          array.toSource()
                          -

                          参数

                          +

                          参数

                          -

                          描述

                          +

                          描述

                          在调试时,你可以使用toSource方法来查看一个数组的内容.

                          -

                          例子

                          +

                          例子

                          -

                          例子: 查看数组的源码

                          +

                          例子: 查看数组的源码

                          var alpha = new Array("a", "b", "c");
                           
                          @@ -33,7 +33,7 @@ alpha.toSource();   //返回["a", "b", "c"]

                          {{Compat("javascript.builtins.Array.toSource")}}

                          -

                          相关链接

                          +

                          相关链接

                          • Array.toString
                          • 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
                            {{EmbedInteractiveExample("pages/js/array-tostring.html")}}
                            -

                            语法

                            +

                            语法

                            arr.toString()
                             
                            -

                            返回值

                            +

                            返回值

                            一个表示指定的数组及其元素的字符串。

                            @@ -72,7 +72,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/toString

                            {{Compat("javascript.builtins.Array.toString")}}

                            -

                            相关链接

                            +

                            相关链接

                            • {{jsxref("Array.prototype.join()")}}
                            • 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
                              {{EmbedInteractiveExample("pages/js/array-unshift.html")}}
                              -

                              语法

                              +

                              语法

                              arr.unshift(element1, ..., elementN)
                               
                              -

                              参数列表

                              +

                              参数列表

                              elementN
                              @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/unshift
                              -

                              描述

                              +

                              描述

                              unshift 方法会在调用它的类数组对象的开始位置插入给定的参数。

                              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 -

                              语法

                              +

                              语法

                              bool.toString()
                              @@ -24,7 +24,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Boolean/toString

                              表示特定{{jsxref("Boolean")}}对象的字符串。

                              -

                              描述

                              +

                              描述

                              {{jsxref("Boolean")}} 对象覆盖了 {{jsxref("Object")}} 对象的  toString 方法。并没有继承 {{jsxref("Object.prototype.toString()")}}。对于布尔对象,toString 方法返回该对象的字符串形式。

                              @@ -78,7 +78,7 @@ var myVar = flag.toString()

                              {{Compat("javascript.builtins.Boolean.toString")}}

                              -

                              相关链接

                              +

                              相关链接

                              • {{jsxref("Object.prototype.toString()")}}
                              • 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 -

                                语法

                                +

                                语法

                                bool.valueOf()
                                @@ -24,15 +24,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Boolean/valueOf

                                给定{{jsxref("Boolean")}}对象的原始值

                                -

                                描述

                                +

                                描述

                                {{jsxref("Boolean")}}的 valueOf 方法返回一个{{jsxref("Boolean")}}对象或{{jsxref("Boolean")}}字面量的原始值作为布尔数据类型。

                                该方法通常在 JavaScript 内部调用,而不是在代码中显式调用。

                                -

                                示例

                                +

                                示例

                                -

                                使用 valueOf

                                +

                                使用 valueOf

                                x = new Boolean();
                                 myVar = x.valueOf()      // assigns false to myVar
                                @@ -74,7 +74,7 @@ myVar = x.valueOf()      // assigns false to myVar
                                 
                                 

                                {{Compat("javascript.builtins.Boolean.valueOf")}}

                                -

                                相关链接

                                +

                                相关链接

                                • {{jsxref("Object.prototype.valueOf()")}}
                                • 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 -

                                  语法

                                  +

                                  语法

                                  dateObj.getDate()
                                  -

                                  参数

                                  +

                                  参数

                                  -

                                  描述

                                  +

                                  描述

                                  getDate() 返回一个1 到 31的整数值。

                                  -

                                  例子

                                  +

                                  例子

                                  -

                                  例子: 使用getDate()方法

                                  +

                                  例子: 使用getDate()方法

                                  下面第二条语句将值25赋给 day 变量,该值基于日期对象 Xmax95的值。

                                  @@ -67,7 +67,7 @@ alert(day); // 25

                                {{Compat("javascript.builtins.Date.getDate")}}

                                -

                                相关链接

                                +

                                相关链接

                                • {{jsxref("Date.prototype.getUTCDate()")}}
                                • 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 -

                                  语法

                                  +

                                  语法

                                  dateObj.getDay()
                                   
                                  -

                                  返回值

                                  +

                                  返回值

                                  根据本地时间,返回一个0到6之间的整数值,代表星期几: 0 代表星期日, 1 代表星期一,2 代表星期二, 依次类推。

                                  -

                                  例子

                                  +

                                  例子

                                  -

                                  使用getDay()

                                  +

                                  使用getDay()

                                  下面第二条语句,基于{{jsxref("Date")}}对象 Xmas95 的值,把 1 赋值给 weekday。也就是说1995年12月25日是星期一。

                                  @@ -77,7 +77,7 @@ console.log(new Intl.DateTimeFormat('de-DE', options).format(Xmas95));

                                  {{Compat("javascript.builtins.Date.getDay")}}

                                  -

                                  相关链接

                                  +

                                  相关链接

                                  • {{jsxref("Date.prototype.getUTCDate()")}}
                                  • 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 -

                                    语法

                                    +

                                    语法

                                    dateObj.getFullYear()
                                     
                                    -

                                    返回值

                                    +

                                    返回值

                                    根据当地时间,返回一个对应于给定日期的年份数字。

                                    @@ -32,9 +32,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getFullYear

                                    getFullYear()返回的值是绝对数。 对于1000到9999之间的日期,getFullYear()返回一个四位数字,如1995。使用此函数确保在2000年后兼容。

                                    -

                                    例子

                                    +

                                    例子

                                    -

                                    使用getFullYear()

                                    +

                                    使用getFullYear()

                                    下面的例子将当前年份的四位数值分配给变量year

                                    @@ -78,7 +78,7 @@ var year = today.getFullYear();

                                    {{Compat("javascript.builtins.Date.getFullYear")}}

                                    -

                                    相关链接

                                    +

                                    相关链接

                                    • {{jsxref("Date.prototype.getUTCFullYear()")}}
                                    • 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
                                      dateObj.getHours()
                                      -

                                      参数

                                      +

                                      参数

                                      -

                                      返回值

                                      +

                                      返回值

                                      getHours返回一个0 到 23之间的整数值。

                                      -

                                      例子

                                      +

                                      例子

                                      -

                                      例子:使用getHours方法

                                      +

                                      例子:使用getHours方法

                                      下面第二条语句,基于日期对象 Xmas95 的值,把 23 赋值给了变量 hours。

                                      @@ -65,7 +65,7 @@ alert(hours); // 23

                                      {{Compat("javascript.builtins.Date.getHours")}}

                                      -

                                      相关链接

                                      +

                                      相关链接

                                      • {{jsxref("Date.prototype.getUTCHours()")}}
                                      • 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 -

                                        语法

                                        +

                                        语法

                                        dateObj.getMilliseconds()
                                        -

                                        参数

                                        +

                                        参数

                                        -

                                        描述

                                        +

                                        描述

                                        getMilliseconds() 方法返回一个0 到 999的整数。

                                        -

                                        例子

                                        +

                                        例子

                                        -

                                        例子:使用getMilliseconds方法

                                        +

                                        例子:使用getMilliseconds方法

                                        下例中,将当前时间的毫秒数赋值给变量 ms

                                        @@ -64,7 +64,7 @@ ms = Today.getMilliseconds();

                                        {{Compat("javascript.builtins.Date.getMilliseconds")}}

                                        -

                                        相关链接

                                        +

                                        相关链接

                                        • {{jsxref("Date.prototype.getUTCMilliseconds()")}}
                                        • 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
                                          {{EmbedInteractiveExample("pages/js/date-getminutes.html")}}
                                          -

                                          语法

                                          +

                                          语法

                                          dateObj.getMinutes()
                                          -

                                          参数

                                          +

                                          参数

                                          -

                                          描述

                                          +

                                          描述

                                          getMinutes 返回一个0 到 59的整数值。

                                          -

                                          例子

                                          +

                                          例子

                                          -

                                          例子:使用getMinutes方法

                                          +

                                          例子:使用getMinutes方法

                                          下例中,第二行语句运行过后,变量 minutes 的值为15,也就是说 Xmas95 这个日期对象的值为某时15分某秒。

                                          @@ -63,7 +63,7 @@ var minutes = Xmas95.getMinutes();

                                          {{Compat("javascript.builtins.Date.getMinutes")}}

                                          -

                                          相关链接

                                          +

                                          相关链接

                                          • {{jsxref("Date.prototype.getUTCMinutes()")}}
                                          • 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 -

                                            语法

                                            +

                                            语法

                                            dateObj.getMonth()
                                            -

                                            参数

                                            +

                                            参数

                                            -

                                            返回值

                                            +

                                            返回值

                                            getMonth返回一个0 到 11的整数值: 0 代表一月份,1 代表二月份, 2 代表三月份,依次类推。

                                            -

                                            例子

                                            +

                                            例子

                                            -

                                            使用 getMonth()

                                            +

                                            使用 getMonth()

                                            下面第二条语句,基于 {{jsxref("Date")}} 对象 Xmas95 的值,把11赋值给变量 month。

                                            @@ -79,7 +79,7 @@ console.log(month); // 11

                                            {{Compat("javascript.builtins.Date.getMonth")}}

                                            -

                                            相关链接

                                            +

                                            相关链接

                                            • {{jsxref("Date.prototype.getUTCMonth()")}}
                                            • 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 -

                                              语法

                                              +

                                              语法

                                              dateObj.getSeconds()
                                              -

                                              参数

                                              +

                                              参数

                                              -

                                              描述

                                              +

                                              描述

                                              该方法返回一个 0 到 59 的整数值。

                                              -

                                              例子

                                              +

                                              例子

                                              -

                                              例子: 使用getSeconds方法

                                              +

                                              例子: 使用getSeconds方法

                                              下面第二条语句,基于日期对象 Xmas95 的值,把 30 赋值给变量 secs

                                              @@ -67,7 +67,7 @@ var secs = Xmas95.getSeconds();

                                              {{Compat("javascript.builtins.Date.getSeconds")}}

                                              -

                                              相关链接

                                              +

                                              相关链接

                                              • {{jsxref("Date.prototype.getUTCSeconds()")}}
                                              • 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 -

                                                语法

                                                +

                                                语法

                                                dateObj.getTime() 
                                                -

                                                参数

                                                +

                                                参数

                                                无。

                                                -

                                                返回值

                                                +

                                                返回值

                                                getTime 方法的返回值一个数值,表示从1970年1月1日0时0分0秒(UTC,即协调世界时)距离该日期对象所代表时间的毫秒数。

                                                -

                                                例子

                                                +

                                                例子

                                                使用 getTime() 复制日期对象

                                                @@ -86,7 +86,7 @@ console.log("Operation took " + (end.getTime() - start.getTime()) + " msec");

                                                {{Compat("javascript.builtins.Date.getTime")}}

                                                -

                                                相关链接

                                                +

                                                相关链接

                                                • {{jsxref("Date.prototype.setTime()")}}
                                                • 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 -

                                                  语法

                                                  +

                                                  语法

                                                  dateObj.getTimezoneOffset()
                                                  -

                                                  参数

                                                  +

                                                  参数

                                                  -

                                                  返回值

                                                  +

                                                  返回值

                                                  时区偏差(time-zone offset)表示协调世界时(UTC)与本地时区之间的差值,单位为分钟。需要注意的是如果本地时区后于协调世界时,则该差值为正值,如果先于协调世界时则为负值。例如你所在时区为 UTC+10(澳大利亚东部标准时间),将会返回 -600。对于同一个时区,夏令时(Daylight Saving Time)将会改变这个值。

                                                  -

                                                  例子

                                                  +

                                                  例子

                                                  -

                                                  例子: 使用getTimezoneOffset方法

                                                  +

                                                  例子: 使用getTimezoneOffset方法

                                                  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
                                                   
                                                   
                                                  {{EmbedInteractiveExample("pages/js/date-getutcdate.html")}}
                                                  -

                                                  语法

                                                  +

                                                  语法

                                                  dateObj.getUTCDate()
                                                  -

                                                  参数

                                                  +

                                                  参数

                                                  -

                                                  返回值

                                                  +

                                                  返回值

                                                  getUTCDate() 返回一个 1 到 31 的整数值

                                                  -

                                                  例子

                                                  +

                                                  例子

                                                  -

                                                  例子: 使用 getUTCDate() 方法

                                                  +

                                                  例子: 使用 getUTCDate() 方法

                                                  下面的例子是把当前日期的天数部分赋值给变量 day.

                                                  @@ -64,7 +64,7 @@ var day = today.getUTCDate();

                                                  {{Compat("javascript.builtins.Date.getUTCDate")}}

                                                  -

                                                  相关链接

                                                  +

                                                  相关链接

                                                  • {{jsxref("Date.prototype.getDate()")}}
                                                  • 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 -

                                                    语法

                                                    +

                                                    语法

                                                    dateObj.getUTCDay()
                                                    -

                                                    参数

                                                    +

                                                    参数

                                                    无。

                                                    -

                                                    返回值

                                                    +

                                                    返回值

                                                    getUTCDay() 方法返回一个对应一星期中第几天的整数:0 代表星期天,1 代表星期一,2 代表星期二,依次类推。

                                                    -

                                                    例子

                                                    +

                                                    例子

                                                    -

                                                    例子: 使用 getUTCDay() 方法

                                                    +

                                                    例子: 使用 getUTCDay() 方法

                                                    下面的例子是把当前日期的星期部分赋值给变量 weekday

                                                    @@ -66,7 +66,7 @@ var weekday = today.getUTCDay();

                                                    {{Compat("javascript.builtins.Date.getUTCDay")}}

                                                    -

                                                    相关链接

                                                    +

                                                    相关链接

                                                    • {{jsxref("Date.prototype.getUTCDate()")}}
                                                    • 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 -

                                                      语法

                                                      +

                                                      语法

                                                      dateObj.getUTCFullYear()
                                                      -

                                                      参数

                                                      +

                                                      参数

                                                      无。

                                                      -

                                                      返回值

                                                      +

                                                      返回值

                                                      getUTCFullYear() 返回一个绝对数值,符合 Year-2000 标准,例如 1995。

                                                      -

                                                      例子

                                                      +

                                                      例子

                                                      -

                                                      例子: 使用 getUTCFullYear() 方法

                                                      +

                                                      例子: 使用 getUTCFullYear() 方法

                                                      下面的例子是把当前年份的四位数值复制给变量 year

                                                      @@ -66,7 +66,7 @@ var year = today.getUTCFullYear();

                                                      {{Compat("javascript.builtins.Date.getUTCFullYear")}}

                                                      -

                                                      相关链接

                                                      +

                                                      相关链接

                                                      • {{jsxref("Date.prototype.getFullYear()")}}
                                                      • 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 -

                                                        语法

                                                        +

                                                        语法

                                                        dateObj.getUTCHours()
                                                        -

                                                        参数

                                                        +

                                                        参数

                                                        无。

                                                        -

                                                        返回值

                                                        +

                                                        返回值

                                                        getUTCHours() 返回一个 0 到 23 的整数。

                                                        -

                                                        例子

                                                        +

                                                        例子

                                                        -

                                                        例子: 使用 getUTCHours() 方法

                                                        +

                                                        例子: 使用 getUTCHours() 方法

                                                        下例将当前时间的小时部分赋值给变量 hours

                                                        @@ -66,7 +66,7 @@ var hours = today.getUTCHours();

                                                        {{Compat("javascript.builtins.Date.getUTCHours")}}

                                                        -

                                                        相关链接

                                                        +

                                                        相关链接

                                                        • {{jsxref("Date.prototype.getHours()")}}
                                                        • 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
                                                          {{EmbedInteractiveExample("pages/js/date-getutcmilliseconds.html")}}
                                                          -

                                                          语法

                                                          +

                                                          语法

                                                          dateObj.getUTCMilliseconds()
                                                          -

                                                          参数

                                                          +

                                                          参数

                                                          无。

                                                          -

                                                          返回值

                                                          +

                                                          返回值

                                                          getUTCMilliseconds() 返回一个 0 到 999 的整数。

                                                          -

                                                          例子

                                                          +

                                                          例子

                                                          -

                                                          例子: 使用 getUTCMilliseconds() 方法

                                                          +

                                                          例子: 使用 getUTCMilliseconds() 方法

                                                          下例将当前时间的毫秒部分赋值给变量 milliseconds

                                                          @@ -64,7 +64,7 @@ var milliseconds = today.getUTCMilliseconds();

                                                          {{Compat("javascript.builtins.Date.getUTCMilliseconds")}}

                                                          -

                                                          相关链接

                                                          +

                                                          相关链接

                                                          • {{jsxref("Date.prototype.getMilliseconds()")}}
                                                          • 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
                                                            {{EmbedInteractiveExample("pages/js/date-getutcminutes.html")}}
                                                            -

                                                            语法

                                                            +

                                                            语法

                                                            dateObj.getUTCMinutes()
                                                            -

                                                            参数

                                                            +

                                                            参数

                                                            无。

                                                            -

                                                            返回值

                                                            +

                                                            返回值

                                                            getUTCMinutes() 返回一个 0 到 59 的整数。

                                                            -

                                                            例子

                                                            +

                                                            例子

                                                            -

                                                            例子: 使用 getUTCMinutes() 方法

                                                            +

                                                            例子: 使用 getUTCMinutes() 方法

                                                            下例将当前时间的分钟部分赋值给变量 minutes

                                                            @@ -64,7 +64,7 @@ var minutes = today.getUTCMinutes();

                                                            {{Compat("javascript.builtins.Date.getUTCMinutes")}}

                                                            -

                                                            相关链接

                                                            +

                                                            相关链接

                                                            • {{jsxref("Date.prototype.getMinutes()")}}
                                                            • 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 -

                                                              语法

                                                              +

                                                              语法

                                                              dateObj.getUTCMonth()
                                                              -

                                                              参数

                                                              +

                                                              参数

                                                              无。

                                                              -

                                                              返回值

                                                              +

                                                              返回值

                                                              getUTCMonth() 返回一个 0 到 11 的整数,分别对应以下月份:0 代表一月,1 代表二月,2 代表三月,依次类推。

                                                              -

                                                              例子

                                                              +

                                                              例子

                                                              -

                                                              例子: 使用 getUTCMonth() 方法

                                                              +

                                                              例子: 使用 getUTCMonth() 方法

                                                              下例将当前时间的月份赋值给变量 month

                                                              @@ -66,7 +66,7 @@ var month = today.getUTCMonth();

                                                              {{Compat("javascript.builtins.Date.getUTCMonth")}}

                                                              -

                                                              相关链接

                                                              +

                                                              相关链接

                                                              • {{jsxref("Date.prototype.getMonth()")}}
                                                              • 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
                                                                {{EmbedInteractiveExample("pages/js/date-getutcseconds.html")}}
                                                                -

                                                                语法

                                                                +

                                                                语法

                                                                dateObj.getUTCSeconds()
                                                                -

                                                                参数

                                                                +

                                                                参数

                                                                无。

                                                                -

                                                                返回值

                                                                +

                                                                返回值

                                                                getUTCSeconds() 返回一个 0 到 59 的整数。

                                                                -

                                                                例子

                                                                +

                                                                例子

                                                                -

                                                                例子: 使用 getUTCSeconds() 方法

                                                                +

                                                                例子: 使用 getUTCSeconds() 方法

                                                                下例将当前时间的秒数部分赋值给变量 seconds

                                                                @@ -64,7 +64,7 @@ var seconds = today.getUTCSeconds();

                                                                {{Compat("javascript.builtins.Date.getUTCSeconds")}}

                                                                -

                                                                相关链接

                                                                +

                                                                相关链接

                                                                • {{jsxref("Date.prototype.getSeconds()")}}
                                                                • 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

                                                                  getYear() 方法返回指定的本地日期的年份。因为 getYear 不返回千禧年[full years] ("year 2000 problem"),所以这个方法不再被使用,现在替换为 {{jsxref("Date.getFullYear", "getFullYear")}} .

                                                                  -

                                                                  Syntax

                                                                  +

                                                                  Syntax

                                                                  dateObj.getYear() 
                                                                  -

                                                                  Parameters

                                                                  +

                                                                  Parameters

                                                                  None.

                                                                  -

                                                                  Returns

                                                                  +

                                                                  Returns

                                                                  The getYear method returns the year minus 1900; thus:

                                                                  @@ -27,9 +27,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getYear

                                                                  To take into account years before and after 2000, you should use {{jsxref("Date.getFullYear", "getFullYear()")}} instead of getYear so that the year is specified in full.

                                                                  -

                                                                  Backward Compatibility

                                                                  +

                                                                  Backward Compatibility

                                                                  -

                                                                  Behaviour in JavaScript 1.2 and earlier

                                                                  +

                                                                  Behaviour in JavaScript 1.2 and earlier

                                                                  The getYear method returns either a 2-digit or 4-digit year:

                                                                  @@ -38,9 +38,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getYear
                                                                • For years less than 1900 or greater than 1999, the value returned by getYear 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.
                                                                -

                                                                Examples

                                                                +

                                                                Examples

                                                                -

                                                                Example: Years between 1900 and 1999

                                                                +

                                                                Example: Years between 1900 and 1999

                                                                The second statement assigns the value 95 to the variable year.

                                                                @@ -48,7 +48,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getYear var year = Xmas.getYear(); // returns 95
                                                  -

                                                  Example: Years above 1999

                                                  +

                                                  Example: Years above 1999

                                                  The second statement assigns the value 100 to the variable year.

                                                  @@ -56,7 +56,7 @@ var year = Xmas.getYear(); // returns 95 var year = Xmas.getYear(); // returns 100 -

                                                  Example: Years below 1900

                                                  +

                                                  Example: Years below 1900

                                                  The second statement assigns the value -100 to the variable year.

                                                  @@ -64,7 +64,7 @@ var year = Xmas.getYear(); // returns 100 var year = Xmas.getYear(); // returns -100 -

                                                  Example: Setting and getting a year between 1900 and 1999

                                                  +

                                                  Example: Setting and getting a year between 1900 and 1999

                                                  The second statement assigns the value 95 to the variable year, representing the year 1995.

                                                  @@ -103,7 +103,7 @@ var year = Xmas.getYear(); // returns 95

                                                  {{Compat("javascript.builtins.Date.getYear")}}

                                                  -

                                                  See also

                                                  +

                                                  See also

                                                  • {{jsxref("Date.prototype.getFullYear()")}}
                                                  • 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 -

                                                    语法

                                                    +

                                                    语法

                                                    显式调用:

                                                    @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse
                                                    new Date(dateString).getTime()
                                                     
                                                    -

                                                    参数

                                                    +

                                                    参数

                                                    dateString
                                                    @@ -42,7 +42,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse
                                                    一个表示从1970-1-1 00:00:00 UTC到给定日期字符串所表示时间的毫秒数的数值。如果参数不能解析为一个有效的日期,则返回{{jsxref("NaN")}}。
                                                    -

                                                    描述

                                                    +

                                                    描述

                                                    parse 方法接受一个日期字符串(例如 "Dec 25, 1995"),并返回从1970-1-1 00:00:00 UTC到该日期字符串所表示日期的毫秒数。该方法在基于字符串值设置日期值时很有用,例如结合使用{{jsxref("Global_Objects/Date/setTime", "setTime()")}} 方法和 {{jsxref("Global_Objects/Date", "Date()")}} 构造函数。

                                                    @@ -60,7 +60,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse

                                                    由于 parse() 是 {{jsxref("Date")}} 的一个静态方法 , 所以应该使用 Date.parse() 来调用,而不是作为 {{jsxref("Date")}} 的实例方法。

                                                    -

                                                    默认时区的区别

                                                    +

                                                    默认时区的区别

                                                    当输入为 "March 7, 2014" 时, parse()  将默认使用本地时区。但如果使用 ISO  格式如 "2014-03-07" ,则会被默认为 UTC (ES5 和 ECMAScript 2015) 时区。  因此除非系统本地时区为 UTC,由这些字符串解析出的 {{jsxref("Date")}}  对象可能会因为 ECMAScript  版本不同而代表不同的时间。这意味着两个看起来等效的字符串可能因为它们的格式不同而被转换成不同的值。

                                                    @@ -91,9 +91,9 @@ new Date('2014-25-23').toISOString(); Date.parse('foo-bar 2014'); // 返回: NaN -

                                                    例子

                                                    +

                                                    例子

                                                    -

                                                    例子:使用 Date.parse()

                                                    +

                                                    例子:使用 Date.parse()

                                                    如果 IPOdate 是一个已经存在的 {{jsxref("Date")}} 对象,则可以把其设置为本地时间 1995年8月9日。如下:

                                                    @@ -169,11 +169,11 @@ Date.parse('foo-bar 2014');

                                                    {{Compat("javascript.builtins.Date.parse")}}

                                                    -

                                                    兼容性提示

                                                    +

                                                    兼容性提示

                                                    Firefox 49 {{geckoRelease(49)}} 修改了解析2位数年份的方式,从和 Internet Explorer 一致改为和 Google Chrome  浏览器一致。现在,2位数的年份小于等于 50  的将会被解析为21世纪的年份。比如, 04/16/17 ,在之前会被解析为 1917年4月16日,现在将被解析为 2017年4月16日。为了避免任何可能的同步问题或者有歧义的年份,推荐使用 ISO 8601 格式如 "2017-04-16" ({{bug(1265136)}})。

                                                    -

                                                    相关链接

                                                    +

                                                    相关链接

                                                    • {{jsxref("Date.UTC()")}}
                                                    • 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 -

                                                      语法

                                                      +

                                                      语法

                                                      dateObj.setDate(dayValue)
                                                      -

                                                      参数

                                                      +

                                                      参数

                                                      dayValue
                                                      一个整数,表示该月的第几天。
                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      如果 dayValue 超出了月份的合理范围,setDate 将会相应地更新 Date 对象。

                                                      @@ -30,9 +30,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setDate

                                                      如果dayValue被设置为负数,日期会设置为上个月最后一天往前数这个负数绝对值天数后的日期。-1会设置为上月最后一天的前一天(译者注:例如当前为4月,如果setDate(-2),则为3月29日)

                                                      -

                                                      例子

                                                      +

                                                      例子

                                                      -

                                                      例子:使用setDate方法

                                                      +

                                                      例子:使用setDate方法

                                                      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

                                                      {{Compat("javascript.builtins.Date.setDate")}}

                                                      -

                                                      相关链接

                                                      +

                                                      相关链接

                                                      • {{jsxref("Date.prototype.getDate()")}}
                                                      • 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 -

                                                        语法

                                                        +

                                                        语法

                                                        dateObj.setFullYear(yearValue[, monthValue[, dayValue]])
                                                        -

                                                        参数

                                                        +

                                                        参数

                                                        yearValue
                                                        @@ -26,15 +26,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setFullYear
                                                        一个1到31之间的整数值,表示月份中的第几天。如果你指定了 dayValue 参数,就必须同时指定 monthValue
                                                        -

                                                        描述

                                                        +

                                                        描述

                                                        如果没有指定 monthValuedayValue 参数,将会使用 getMonthgetDate 方法的返回值。

                                                        如果有一个参数超出了合理的范围,setFullYear 方法会更新其他参数值,日期对象的日期值也会被相应更新。 例如,为 monthValue 指定 15, 则年份会加1,月份值会为3。

                                                        -

                                                        例子

                                                        +

                                                        例子

                                                        -

                                                        例子:使用setFullYear方法

                                                        +

                                                        例子:使用setFullYear方法

                                                        var theBigDay = new Date();
                                                         theBigDay.setFullYear(1997);
                                                        @@ -70,7 +70,7 @@ theBigDay.setFullYear(1997);

                                                        {{Compat("javascript.builtins.Date.setFullYear")}}

                                                        -

                                                        相关链接

                                                        +

                                                        相关链接

                                                        • {{jsxref("Date.prototype.getUTCFullYear()")}}
                                                        • 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 -

                                                          语法

                                                          +

                                                          语法

                                                          dateObj.setHours(hoursValue[, minutesValue[, secondsValue[, msValue]]])
                                                           
                                                          -

                                                          JavaScript 1.3版本之前

                                                          +

                                                          JavaScript 1.3版本之前

                                                          dateObj.setHours(hoursValue) 
                                                          -

                                                          参数

                                                          +

                                                          参数

                                                          hoursValue
                                                          @@ -33,15 +33,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setHours
                                                          一个 0 到 999 的数字,表示微秒数,如果指定了 msValue 参数,则必须同时指定 minutesValue 和 secondsValue 参数。
                                                          -

                                                          描述

                                                          +

                                                          描述

                                                          如果不指定 minutesValuesecondsValue 和 msValue 参数,则会使用{{jsxref("Date.getMinutes", "getMinutes()")}},{{jsxref("Date.getSeconds", "getSeconds()")}} 和{{jsxref("Date.getMilliseconds", "getMilliseconds()")}} 方法的返回值。

                                                          如果有一个参数超出了合理范围,setHours 会相应地更新日期对象中的日期信息。例如,如果为 secondsValue 指定了 100,则分钟会加 1,然后秒数使用 40。

                                                          -

                                                          例子

                                                          +

                                                          例子

                                                          -

                                                          例子:使用setHours方法

                                                          +

                                                          例子:使用setHours方法

                                                          var theBigDay = new Date();
                                                           theBigDay.setHours(7);
                                                          @@ -78,7 +78,7 @@ theBigDay.setHours(7);
                                                           
                                                           

                                                          {{Compat("javascript.builtins.Date.setHours")}}

                                                          -

                                                          相关链接

                                                          +

                                                          相关链接

                                                          • {{jsxref("Date.prototype.getHours()")}}
                                                          • 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 -

                                                            语法

                                                            +

                                                            语法

                                                            dateObj.setMilliseconds(millisecondsValue)
                                                            -

                                                            参数

                                                            +

                                                            参数

                                                            millisecondsValue
                                                            一个 0 到 999 的数字,表示豪秒数。
                                                            -

                                                            描述

                                                            +

                                                            描述

                                                            如果指定的数字超出了合理范围,则日期对象的时间信息会被相应地更新。例如,如果指定了 1005,则秒数加 1,豪秒数为 5。

                                                            -

                                                            例子

                                                            +

                                                            例子

                                                            -

                                                            例子:使用setMilliseconds

                                                            +

                                                            例子:使用setMilliseconds

                                                            var theBigDay = new Date();
                                                             theBigDay.setMilliseconds(100);
                                                            @@ -65,7 +65,7 @@ theBigDay.setMilliseconds(100);
                                                             
                                                             

                                                            {{Compat("javascript.builtins.Date.setMilliseconds")}}

                                                            -

                                                            相关链接

                                                            +

                                                            相关链接

                                                            • {{jsxref("Date.prototype.getMilliseconds()")}}
                                                            • 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 -

                                                              语法

                                                              +

                                                              语法

                                                              dateObj.setMinutes(minutesValue[, secondsValue[, msValue]])
                                                              -

                                                               JavaScript 1.3之前版本

                                                              +

                                                               JavaScript 1.3之前版本

                                                              dateObj.setMinutes(minutesValue)
                                                              -

                                                              参数

                                                              +

                                                              参数

                                                              minutesValue
                                                              @@ -36,15 +36,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setMinutes
                                                              一个 0 到 999 的数字,表示微秒数,如果指定了 msValue 参数,则必须同时指定 minutesValuesecondsValue 参数。
                                                              -

                                                              描述

                                                              +

                                                              描述

                                                              如果没有指定 secondsValuemsValue 参数,就会使用 {{jsxref("Date.getSeconds", "getSeconds()")}} 和 {{jsxref("Date.getMilliseconds", "getmilliseconds()")}} 方法的返回值。

                                                              如果有一个指定的参数超出了合理范围,setMinutes 会相应地更新日期对象中的时间信息。例如,为 secondsValue 指定 100,分钟数将会加 1,而秒数会为 40。

                                                              -

                                                              例子

                                                              +

                                                              例子

                                                              -

                                                              例子:使用setMinutes方法

                                                              +

                                                              例子:使用setMinutes方法

                                                              var theBigDay = new Date();
                                                               theBigDay.setMinutes(45);
                                                              @@ -81,7 +81,7 @@ theBigDay.setMinutes(45);
                                                               
                                                               

                                                              {{Compat("javascript.builtins.Date.setMinutes")}}

                                                              -

                                                              相关链接

                                                              +

                                                              相关链接

                                                              • {{jsxref("Date.prototype.getMinutes()")}}
                                                              • 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
                                                                {{EmbedInteractiveExample("pages/js/date-setmonth.html")}}
                                                                -

                                                                语法

                                                                +

                                                                语法

                                                                dateObj.setMonth(monthValue[, dayValue])
                                                                -

                                                                JavaScript 1.3版本之前

                                                                +

                                                                JavaScript 1.3版本之前

                                                                dateObj.setMonth(monthValue)
                                                                -

                                                                参数

                                                                +

                                                                参数

                                                                monthValue
                                                                @@ -31,15 +31,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setMonth
                                                                基于 1 January 1970 00:00:00 UTC 开始计算的毫秒数
                                                                -

                                                                描述

                                                                +

                                                                描述

                                                                如果不指定 dayValue 参数,就会使用 {{jsxref("Date.getDate", "getDate")}} 方法的返回值。

                                                                如果有一个指定的参数超出了合理范围,setMonth 会相应地更新日期对象中的日期信息。例如,为 monthValue 指定 15,则年份会加 1,月份将会使用 3。

                                                                -

                                                                例子

                                                                +

                                                                例子

                                                                -

                                                                例子:使用setMonth方法

                                                                +

                                                                例子:使用setMonth方法

                                                                var theBigDay = new Date();
                                                                 theBigDay.setMonth(6);
                                                                @@ -76,7 +76,7 @@ theBigDay.setMonth(6);
                                                                 
                                                                 

                                                                {{Compat("javascript.builtins.Date.setMonth")}}

                                                                -

                                                                相关链接

                                                                +

                                                                相关链接

                                                                • {{jsxref("Date.prototype.getMonth()")}}
                                                                • 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 -

                                                                  语法

                                                                  +

                                                                  语法

                                                                  dateObj.setSeconds(secondsValue[, msValue])
                                                                  @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setSeconds
                                                                  dateObj.setSeconds(secondsValue)
                                                                  -

                                                                  参数

                                                                  +

                                                                  参数

                                                                  secondsValue
                                                                  @@ -28,15 +28,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setSeconds
                                                                  一个 0 到 999 的数字,表示微秒数。
                                                                  -

                                                                  描述

                                                                  +

                                                                  描述

                                                                  如果没有指定 msValue 参数,就会使用 {{jsxref("Date.getMilliseconds", "getMilliseconds()")}} 方法的返回值。

                                                                  如果一个参数超出了合理范围, setSeconds 方法会相应地更新日期对象的时间信息。例如,为 secondsValue 指定 100,则日期对象的分钟数会相应地加 1,秒数将会使用 40。

                                                                  -

                                                                  例子

                                                                  +

                                                                  例子

                                                                  -

                                                                  例子:使用setSeconds方法

                                                                  +

                                                                  例子:使用setSeconds方法

                                                                  var theBigDay = new Date();
                                                                   theBigDay.setSeconds(30)
                                                                  @@ -73,7 +73,7 @@ theBigDay.setSeconds(30)
                                                                   
                                                                   

                                                                  {{Compat("javascript.builtins.Date.setSeconds")}}

                                                                  -

                                                                  相关链接

                                                                  +

                                                                  相关链接

                                                                  • {{jsxref("Date.prototype.getSeconds()")}}
                                                                  • 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 -

                                                                    语法

                                                                    +

                                                                    语法

                                                                    dateObj.setTime(timeValue)
                                                                    -

                                                                    参数

                                                                    +

                                                                    参数

                                                                    timeValue
                                                                    一个整数,表示从1970-1-1 00:00:00 UTC开始计时的毫秒数。
                                                                    -

                                                                    返回值

                                                                    +

                                                                    返回值

                                                                    UTC 1970年1月1日00:00:00与更新日期之间的毫秒数(实际上是自变量的值)。
                                                                    -

                                                                    描述

                                                                    +

                                                                    描述

                                                                    使用 setTime 方法用来把一个日期时间赋值给另一个 Date 对象。

                                                                    -

                                                                    例子

                                                                    +

                                                                    例子

                                                                    -

                                                                    例子:使用setTime

                                                                    +

                                                                    例子:使用setTime

                                                                    theBigDay = new Date("July 1, 1999");
                                                                     sameAsBigDay = new Date();
                                                                    @@ -70,7 +70,7 @@ sameAsBigDay.setTime(theBigDay.getTime());
                                                                     
                                                                     

                                                                    {{Compat("javascript.builtins.Date.setTime")}}

                                                                    -

                                                                    相关链接

                                                                    +

                                                                    相关链接

                                                                    • {{jsxref("Date.prototype.getTime()")}}
                                                                    • 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 -

                                                                      语法

                                                                      +

                                                                      语法

                                                                      dateObj.setUTCDate(dayValue)
                                                                      -

                                                                      参数

                                                                      +

                                                                      参数

                                                                      dayValue
                                                                      一个1-31的整形数字,用来指定日期。
                                                                      -

                                                                      描述

                                                                      +

                                                                      描述

                                                                      如果你指定的参数超出了范围,setUTCDate()会尝试更新对应的{{jsxref("Global_Objects/Date", "Date")}} 中的日期信息。例如,如果你使用了40来作为参数,但是{{jsxref("Global_Objects/Date", "Date")}} 中存储的月份为6月,那么日期将被改写为10且月份被增到7月。

                                                                      -

                                                                      示例

                                                                      +

                                                                      示例

                                                                      -

                                                                      使用Using setUTCDate()

                                                                      +

                                                                      使用Using setUTCDate()

                                                                      var theBigDay = new Date();
                                                                       theBigDay.setUTCDate(20);
                                                                      @@ -67,7 +67,7 @@ theBigDay.setUTCDate(20);
                                                                       

                                                                      {{Compat("javascript.builtins.Date.setUTCDate")}}

                                                                      -

                                                                      相关内容

                                                                      +

                                                                      相关内容

                                                                      • {{jsxref("Date.prototype.getUTCDate()")}}
                                                                      • 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 -

                                                                        语法

                                                                        +

                                                                        语法

                                                                        dateObj.toDateString()
                                                                        -

                                                                        描述

                                                                        +

                                                                        描述

                                                                        {{jsxref("Global_Objects/Date", "Date")}} 对象实例引用一个具体的时间点。调用 {{jsxref("Date.toString", "toString")}} 方法会以美式英语和人类易读的形式返回日期对象的格式化字符串。在 SpiderMonkey 里,该字符串由日期部分(年月日)和其后的时间部分(时分秒及时区)组成。有时需要获取日期部分的字符串,这可以由 toDateString 方法完成。

                                                                        The toDateString method is especially useful because compliant engines implementing ECMA-262 may differ in the string obtained from toString for Date objects, as the format is implementation-dependent and simple string slicing approaches may not produce consistent results across multiple engines.

                                                                        -

                                                                        例子

                                                                        +

                                                                        例子

                                                                        -

                                                                        例子:toDateString 方法的简单使用

                                                                        +

                                                                        例子:toDateString 方法的简单使用

                                                                        var d = new Date(1993, 6, 28, 14, 39, 7);
                                                                         
                                                                        @@ -61,7 +61,7 @@ println(d.toDateString()); // prints Wed Jul 28 1993

                                                                        {{Compat("javascript.builtins.Date.toDateString")}}

                                                                        -

                                                                        相关链接

                                                                        +

                                                                        相关链接

                                                                        • {{jsxref("Date.prototype.toLocaleDateString()")}}
                                                                        • 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

                                                                          Note: toGMTString is deprecated and should no longer be used, it's only there for backwards compatibility, use {{jsxref("Date.toUTCString", "toUTCString()")}} instead.

                                                                          -

                                                                          Syntax

                                                                          +

                                                                          Syntax

                                                                          dateObj.toGMTString()
                                                                          -

                                                                          Examples

                                                                          +

                                                                          Examples

                                                                          -

                                                                          Example: Using toGMTString

                                                                          +

                                                                          Example: Using toGMTString

                                                                          In this example, the toGMTString 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.

                                                                          @@ -56,7 +56,7 @@ console.log(str); // Mon, 18 Dec 1995 17:28:35 GMT

                                                                          {{Compat("javascript.builtins.Date.toGMTString")}}

                                                                          -

                                                                          See also

                                                                          +

                                                                          See also

                                                                          • {{jsxref("Date.prototype.toLocaleDateString()")}}
                                                                          • 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 -

                                                                            语法

                                                                            +

                                                                            语法

                                                                            dateObj.toISOString()
                                                                            @@ -23,7 +23,7 @@ alert(today.toISOString()); // 返回2011-10-05T14:48:00.000Z

                                                                            上例使用了非标准字符串的解析,该字符串在某些旧的浏览器(如IE)中可能无法被正确解析。

                                                                            -

                                                                            Polyfill

                                                                            +

                                                                            Polyfill

                                                                            该方法在ECMA-262第5版中被标准化。对于那些不支持此方法的JS引擎可以通过加上下面的代码实现:

                                                                            @@ -78,7 +78,7 @@ alert(today.toISOString()); // 返回2011-10-05T14:48:00.000Z

                                                                            {{Compat("javascript.builtins.Date.toISOString")}}

                                                                            -

                                                                            相关链接

                                                                            +

                                                                            相关链接

                                                                            • {{jsxref("Date.prototype.toLocaleDateString()")}}
                                                                            • 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 -

                                                                              语法

                                                                              +

                                                                              语法

                                                                              dateObj.toJSON()
                                                                               
                                                                              -

                                                                              描述

                                                                              +

                                                                              描述

                                                                              {{jsxref("Date")}} 实例引用一个具体的时间点。 调用 toJSON() 返回一个 JSON 格式字符串(使用 {{jsxref("Date.prototype.toISOString()", "toISOString()")}}),表示该日期对象的值。默认情况下,这个方法常用于 {{Glossary("JSON")}}序列化{{jsxref("Date")}}对象。

                                                                              -

                                                                              样例

                                                                              +

                                                                              样例

                                                                              -

                                                                              toJSON() 样例

                                                                              +

                                                                              toJSON() 样例

                                                                              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
                                                                               
                                                                               
                                                                               
                                                                              -

                                                                              语法

                                                                              +

                                                                              语法

                                                                              dateObj.toLocaleDateString([locales [, options]])
                                                                              -

                                                                              参数

                                                                              +

                                                                              参数

                                                                               查看浏览器兼容性小节,看下哪些浏览器支持 locales 和 options 参数,还可以参看例子: 检测 localesoptions 参数支持情况

                                                                              @@ -23,9 +23,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString

                                                                              The default value for each date-time component property is undefined, but if the weekday, year, month, day properties are all undefined, then year, month, and day are assumed to be "numeric".

                                                                              -

                                                                              例子

                                                                              +

                                                                              例子

                                                                              -

                                                                              例子:使用toLocaleDateString

                                                                              +

                                                                              例子:使用toLocaleDateString

                                                                              没有指定语言环境(locale)时,返回一个使用默认语言环境和格式设置(options)的格式化字符串。

                                                                              @@ -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
                                                                              -

                                                                              例子:检测 localesoptions 参数支持情况

                                                                              +

                                                                              例子:检测 localesoptions 参数支持情况

                                                                              locales 和 options 参数不是所有的浏览器都支持。为了检测一种实现环境(implementation)是否支持它们,可以使用不合法的语言标签,如果实现环境支持该参数,则会抛出一个 RangeError 异常,反之会忽略参数。

                                                                              @@ -50,7 +50,7 @@ date.toLocaleDateString(); }
                                                                      -

                                                                      例子:使用locales

                                                                      +

                                                                      例子:使用locales

                                                                      下例展示了本地化日期格式的一些变化。为了在应用的用户界面得到某种语言的日期格式,必须确保使用 locales 参数指定了该语言(可能还需要设置某些回退语言)。

                                                                      @@ -86,7 +86,7 @@ alert(date.toLocaleDateString(["ban", "id"])); // → "20/12/2012"
                                                                    -

                                                                    例子:使用options

                                                                    +

                                                                    例子:使用options

                                                                    可以使用 options 参数来自定义 toLocaleDateString 方法返回的字符串。

                                                                    @@ -104,7 +104,7 @@ alert(date.toLocaleDateString("en-US", options)); // → "Thursday, December 20, 2012, GMT"
                                                                  -

                                                                  性能

                                                                  +

                                                                  性能

                                                                  当格式化大量日期时,最好创建一个 Intl.DateTimeFormat 对象,然后使用该对象 format 属性提供的方法。

                                                                  @@ -144,7 +144,7 @@ alert(date.toLocaleDateString("en-US", options));

                                                                  {{Compat("javascript.builtins.Date.toLocaleDateString")}}

                                                                  -

                                                                  相关链接

                                                                  +

                                                                  相关链接

                                                                  • {{jsxref("Global_Objects/DateTimeFormat", "DateTimeFormat")}}
                                                                  • 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 -

                                                                    语法

                                                                    +

                                                                    语法

                                                                    dateObj.toLocaleString([locales [, options]])
                                                                    -

                                                                    参数

                                                                    +

                                                                    参数

                                                                    查看浏览器兼容性小节,看下哪些浏览器支持 locales 和 options 参数,还可以参看例子:检测 localesoptions 参数支持情况

                                                                    @@ -27,9 +27,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

                                                                    根据当地语言规定返回代表着时间的字符串。

                                                                    -

                                                                    例子

                                                                    +

                                                                    例子

                                                                    -

                                                                    例子:使用 toLocaleString

                                                                    +

                                                                    例子:使用 toLocaleString

                                                                    没有指定语言环境(locale)时,返回一个使用默认语言环境和格式设置(options)的格式化字符串。

                                                                    @@ -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"
                                                                -

                                                                例子:检测 locales 和 options 参数支持情况

                                                                +

                                                                例子:检测 locales 和 options 参数支持情况

                                                                locales 和 options 参数不是所有的浏览器都支持。为了检测一种实现环境(implementation)是否支持它们,可以使用不合法的语言标签,如果实现环境支持该参数,则会抛出一个 RangeError 异常,反之会忽略参数。

                                                                @@ -54,7 +54,7 @@ date.toLocaleString(); }
                                                              -

                                                              例子:使用 locales 参数

                                                              +

                                                              例子:使用 locales 参数

                                                              下例展示了本地化日期格式的一些变化。为了在应用的用户界面得到某种语言的日期和时间格式,必须确保使用 locales 参数指定了该语言(可能还需要设置某些回退语言)。

                                                              @@ -88,7 +88,7 @@ alert(date.toLocaleString(["ban", "id"])); // → "20/12/2012 11.00.00"
                                                            -

                                                            例子:使用 options 参数

                                                            +

                                                            例子:使用 options 参数

                                                            可以使用 options 参数来自定义 toLocaleString 方法返回的字符串。

                                                            @@ -110,7 +110,7 @@ alert(date.toLocaleString("en-US", {hour12: false})); // → "12/19/2012, 19:00:00"
                                                          -

                                                          性能

                                                          +

                                                          性能

                                                          当格式化大量日期时,最好创建一个 Intl.DateTimeFormat 对象,然后使用该对象 format 属性提供的方法。

                                                          @@ -150,7 +150,7 @@ alert(date.toLocaleString("en-US", {hour12: false}));

                                                          {{Compat("javascript.builtins.Date.toLocaleString")}}

                                                          -

                                                          相关链接

                                                          +

                                                          相关链接

                                                          • {{jsxref("Global_Objects/DateTimeFormat", "DateTimeFormat")}}
                                                          • 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 -

                                                            语法

                                                            +

                                                            语法

                                                            dateObj.toLocaleTimeString([locales [, options]])
                                                            -

                                                            参数

                                                            +

                                                            参数

                                                            查看浏览器兼容性小节,看下哪些浏览器支持 locales 和 options 参数,还可以参看例子:检测 localesoptions 参数支持情况

                                                            @@ -23,9 +23,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString

                                                            The default value for each date-time component property is undefined, but if the hour, minute, second properties are all undefined, then hour, minute, and second are assumed to be "numeric".

                                                            -

                                                            例子

                                                            +

                                                            例子

                                                            -

                                                            例子:使用 toLocaleTimeString

                                                            +

                                                            例子:使用 toLocaleTimeString

                                                            没有指定语言环境(locale)时,返回一个使用默认语言环境和格式设置(options)的格式化字符串。

                                                            @@ -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 -

                                                            例子:检测 localesoptions 支持情况

                                                            +

                                                            例子:检测 localesoptions 支持情况

                                                            locales 和 options 参数不是所有的浏览器都支持。为了检测一种实现环境(implementation)是否支持它们,可以使用不合法的语言标签,如果实现环境支持该参数,则会抛出一个 RangeError 异常,反之会忽略参数。

                                                            @@ -50,7 +50,7 @@ alert(date.toLocaleTimeString()); } -

                                                            例子:使用 locales 参数

                                                            +

                                                            例子:使用 locales 参数

                                                            下例展示了本地化时间格式的一些变化。为了在应用的用户界面得到某种语言的时间格式,必须确保使用 locales 参数指定了该语言(可能还需要设置某些回退语言)。

                                                            @@ -81,7 +81,7 @@ alert(date.toLocaleTimeString(["ban", "id"])); // → "11.00.00" -

                                                            例子:使用 options 参数

                                                            +

                                                            例子:使用 options 参数

                                                            可以使用 options 参数来自定义 toLocaleTimeString 方法返回的字符串。

                                                            @@ -97,7 +97,7 @@ alert(date.toLocaleTimeString("en-US", {hour12: false})); // → "19:00:00" -

                                                            性能

                                                            +

                                                            性能

                                                            当格式化大量日期时,最好创建一个 Intl.DateTimeFormat 对象,然后使用该对象 format 属性提供的方法。

                                                            @@ -139,7 +139,7 @@ alert(date.toLocaleTimeString("en-US", {hour12: false}));

                                                            {{Compat("javascript.builtins.Date.toLocaleTimeString")}}

                                                            -

                                                            相关链接

                                                            +

                                                            相关链接

                                                            • {{jsxref("Global_Objects/DateTimeFormat", "DateTimeFormat")}}
                                                            • 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 -

                                                              语法

                                                              +

                                                              语法

                                                              dateObj.toString()
                                                              -

                                                              参数

                                                              +

                                                              参数

                                                              -

                                                              描述

                                                              +

                                                              描述

                                                              {{jsxref("Date")}}对象覆盖了 {{jsxref("Object")}} 对象的 toString() 方法;它不是继承自 {{jsxref("Object.prototype.toString()")}}。对于  {{jsxref("Date")}} 对象,toString() 方法返回一个表示该对象的字符串。

                                                              @@ -29,9 +29,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toString

                                                              toString() 是通用函数。如果不是{{jsxref("Date")}}实例,则 返回"Invalid Date"。

                                                              -

                                                              例子

                                                              +

                                                              例子

                                                              -

                                                              例子: 使用 toString 方法

                                                              +

                                                              例子: 使用 toString 方法

                                                              下例把一个{{jsxref("Date")}}对象的 toString 返回值赋给 myVar:

                                                              @@ -78,7 +78,7 @@ myVar = x.toString(); // 把类似于下面格式的值赋给 myVar,

                                                              {{Compat("javascript.builtins.Date.toString")}}

                                                              -

                                                              相关链接

                                                              +

                                                              相关链接

                                                              • {{jsxref("Object.prototype.toString()")}}
                                                              • 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 -

                                                                语法

                                                                +

                                                                语法

                                                                dateObj.toTimeString()
                                                                -

                                                                描述

                                                                +

                                                                描述

                                                                {{jsxref("Global_Objects/Date", "Date")}} 对象的实例引用一个具体的时间点。 调用 {{jsxref("Date.toString", "toString")}} 方法以美式英语和人类易读的形式,返回日期对象的格式化字符串。在 SpiderMonkey 里,该字符串由日期部分(年月日)和其后的时间部分(时分秒和时区)组成。有时会需要获取时间部分的字符串,这可以由 toTimeString 方法完成。

                                                                The toTimeString method is especially useful because compliant engines implementing ECMA-262 may differ in the string obtained from toString for Date objects, as the format is implementation-dependent; simple string slicing approaches may not produce consistent results across multiple engines.

                                                                -

                                                                例子

                                                                +

                                                                例子

                                                                -

                                                                例子:toTimeString 方法的简单使用

                                                                +

                                                                例子:toTimeString 方法的简单使用

                                                                var d = new Date(1993, 6, 28, 14, 39, 7);
                                                                 
                                                                @@ -62,7 +62,7 @@ println(d.toTimeString()); // prints 14:39:07 GMT-0600 (PDT)
                                                                 
                                                                 

                                                                {{Compat("javascript.builtins.Date.toTimeString")}}

                                                                -

                                                                相关链接

                                                                +

                                                                相关链接

                                                                • {{jsxref("Date.prototype.toLocaleTimeString()")}}
                                                                • 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 -

                                                                  语法

                                                                  +

                                                                  语法

                                                                  dateObj.toUTCString()
                                                                  -

                                                                  返回值

                                                                  +

                                                                  返回值

                                                                  返回使用UTC时区表示给定日期的字符串

                                                                   

                                                                  -

                                                                  描述

                                                                  +

                                                                  描述

                                                                  toUTCString 的返回值是一个使用UTC时区的易读格式字符串。返回值的格式可能随平台而变化。通常返回值是一个 RFC-1123 格式的时间戳,这是一个 RFC-822 时间戳的小幅更新版。

                                                                  -

                                                                  例子

                                                                  +

                                                                  例子

                                                                  -

                                                                  例子:使用toUTCString

                                                                  +

                                                                  例子:使用toUTCString

                                                                  var today = new Date();
                                                                   var UTCstring = today.toUTCString();
                                                                  @@ -65,7 +65,7 @@ var UTCstring = today.toUTCString();
                                                                   
                                                                   

                                                                  {{Compat("javascript.builtins.Date.toUTCString")}}

                                                                  -

                                                                  相关链接

                                                                  +

                                                                  相关链接

                                                                  • {{jsxref("Date.prototype.toLocaleString()")}}
                                                                  • 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 -

                                                                    语法

                                                                    +

                                                                    语法

                                                                    Date.UTC(year,month[,date[,hrs[,min[,sec{{mediawiki.external(',ms')}}]]]]) 
                                                                    -

                                                                    参数

                                                                    +

                                                                    参数

                                                                    year
                                                                    @@ -38,7 +38,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/UTC
                                                                    0 到 999 之间的一个整数,表示毫秒。
                                                                    -

                                                                    描述

                                                                    +

                                                                    描述

                                                                    UTC 方法接受以逗号隔开的日期参数,返回1970-1-1 00:00:00 UTC到指定的日期之间的毫秒数。

                                                                    @@ -55,9 +55,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/UTC

                                                                    由于 UTCDate(日期对象)的一个静态方法,所以应该在 Date 上直接调用,就像 Date.UTC(),而不要把它作为创建的日期对象的方法。

                                                                    -

                                                                    例子

                                                                    +

                                                                    例子

                                                                    -

                                                                    例子:使用 Date.UTC

                                                                    +

                                                                    例子:使用 Date.UTC

                                                                    下面的语句使用 UTC 时间代替本地时间创建了一个日期对象。

                                                                    @@ -95,7 +95,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/UTC

                                                                    {{Compat("javascript.builtins.Date.UTC")}}

                                                                    -

                                                                    相关链接

                                                                    +

                                                                    相关链接

                                                                    • {{jsxref("Date.parse()")}}
                                                                    • 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
                                                                      {{EmbedInteractiveExample("pages/js/date-valueof.html")}}
                                                                      -

                                                                      语法

                                                                      +

                                                                      语法

                                                                      dateObj.valueOf()
                                                                      -

                                                                      返回值

                                                                      +

                                                                      返回值

                                                                      从1970年1月1日0时0分0秒(UTC,即协调世界时)到该日期的毫秒数。

                                                                      -

                                                                      描述

                                                                      +

                                                                      描述

                                                                      valueOf 方法返回以数值格式表示的一个 Date 对象的原始值,从1970年1月1日0时0分0秒(UTC,即协调世界时)到该日期对象所代表时间的毫秒数。

                                                                      @@ -32,9 +32,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/valueOf

                                                                      该方法通常在 JavaScript 内部被调用,而不是在代码中显式调用。

                                                                      -

                                                                      例子

                                                                      +

                                                                      例子

                                                                      -

                                                                      使用 valueOf()

                                                                      +

                                                                      使用 valueOf()

                                                                      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
                                                                       
                                                                       

                                                                      {{Compat("javascript.builtins.Date.valueOf")}}

                                                                      -

                                                                      相关链接

                                                                      +

                                                                      相关链接

                                                                      • {{jsxref("Object.prototype.valueOf()")}}
                                                                      • 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

                                                                        通过Error的构造器可以创建一个错误对象。当运行时错误产生时,Error的实例对象会被抛出。Error对象也可用于用户自定义的异常的基础对象。下面列出了各种内建的标准错误类型。

                                                                        -

                                                                        语法

                                                                        +

                                                                        语法

                                                                        new Error([message[, fileName[,lineNumber]]])
                                                                        -

                                                                        参数

                                                                        +

                                                                        参数

                                                                        message
                                                                        @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error
                                                                        可选。被创建的Error对象的lineNumber属性值。默认是调用Error构造器代码所在的文件的行号。
                                                                        -

                                                                        描述

                                                                        +

                                                                        描述

                                                                        当代码运行时的发生错误,会创建新的Error 对象,并将其抛出。

                                                                        @@ -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!');
                                                                      -

                                                                      Error 类型

                                                                      +

                                                                      Error 类型

                                                                      除了通用的Error构造函数外,JavaScript还有6个其他类型的错误构造函数。更多客户端异常,详见 Exception Handling Statements

                                                                      @@ -83,18 +83,18 @@ const y = new Error('I was constructed via the "new" keyword!');
                                                                  创建一个error实例,表示错误的原因:给 {{jsxref("Global_Objects/encodeURI", "encodeURI()")}}或  {{jsxref("Global_Objects/decodeURI", "decodeURI()")}}传递的参数无效。
                              -

                              属性

                              +

                              属性

                              {{jsxref("Error.prototype")}}
                              允许添加属性到Error实例。
                              -

                              方法

                              +

                              方法

                              全局Error对象自身不包含任何方法,但从原型链中继承了一些方法.

                              -

                              Error 实例

                              +

                              Error 实例

                              {{page('en-US/docs/JavaScript/Reference/Global_Objects/Error/prototype', 'Description')}}

                              @@ -108,9 +108,9 @@ const y = new Error('I was constructed via the "new" keyword!');

                              {{page('en-US/docs/JavaScript/Reference/Global_Objects/Error/prototype', 'Methods')}}

                              -

                              例子

                              +

                              例子

                              -

                              抛出一个基本错误

                              +

                              抛出一个基本错误

                              通常你会使用{{jsxref("Statements/throw", "throw")}}关键字来抛出你创建的Error对象。可以使用 {{jsxref("Statements/try...catch", "try...catch")}} 结构来处理异常:

                              @@ -121,7 +121,7 @@ const y = new Error('I was constructed via the "new" keyword!'); } -

                              处理一个特定错误

                              +

                              处理一个特定错误

                              你可以通过判断异常的类型来特定处理某一类的异常,即判断 {{jsxref("Object.prototype.constructor", "constructor")}} 属性,当使用现代Javascript引擎时,可使用{{jsxref("Operators/instanceof", "instanceof")}} 关键字:

                              @@ -248,7 +248,7 @@ try {
                              {{Compat("javascript.builtins.Error")}}
                              -

                              相关链接

                              +

                              相关链接

                              • {{jsxref("Error.prototype")}}
                              • 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 ---
                                {{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}
                                -

                                概述

                                +

                                概述

                                message 属性是有关错误信息,人类易读的(human-readable)描述。

                                -

                                描述

                                +

                                描述

                                如果该属性已经被设置,则该属性包含了错误的一个简短描述。SpiderMonkey 大量应用 message 属性在异常方面。 message 属性结合 {{jsxref("Error.prototype.name", "name")}} 属性一起被  {{jsxref("Error.prototype.toString()")}} 方法用来创建错误的字符串形式。

                                默认情况下,message 属性是一个空字符串,但是可以通过指定一段信息作为 {{jsxref("Error", "Error constructor")}} 的第一个参数创建一个实例来改变该属性值。

                                -

                                示例

                                +

                                示例

                                -

                                例子:抛出一个自定义错误

                                +

                                例子:抛出一个自定义错误

                                var e = new Error("Could not parse input"); // e.message is "Could not parse input"
                                 throw e;
                                @@ -102,7 +102,7 @@ throw e;
                                 
                                 
                                 
                                -

                                相关链接

                                +

                                相关链接

                                • {{jsxref("Error.prototype.name")}}
                                • 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 ---

                                  {{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}

                                  -

                                  概述

                                  +

                                  概述

                                  name 属性表示error类型的名称.初始值为"Error".

                                  -

                                  描述

                                  +

                                  描述

                                  默认情况下,{{jsxref("Error")}}对象的name属性值为"Error".name属性和{{jsxref("Error.prototype.message", "message")}}属性一起,通过调用{{jsxref("Error.prototype.toString()")}}方法,会作为最后异常信息的字符串表示.

                                  -

                                  示例

                                  +

                                  示例

                                  -

                                  例子: 抛出一个自定义错误

                                  +

                                  例子: 抛出一个自定义错误

                                  var e = new Error("Malformed input"); // e.name默认是"Error"
                                   
                                  @@ -102,7 +102,7 @@ throw e;                              // "ParseError: Malformed input"
                                   
                                   
                                   
                                  -

                                  相关链接

                                  +

                                  相关链接

                                  • {{jsxref("Error.prototype.message")}}
                                  • 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 ---
                                    {{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}
                                    -

                                    概述

                                    +

                                    概述

                                    toString() 方法返回一个指定的错误对象(Error object)的字符串表示。

                                    -

                                    语法

                                    +

                                    语法

                                    e.toString();
                                    -

                                    描述

                                    +

                                    描述

                                    {{jsxref("Error")}} 对象覆盖了 {{jsxref("Object.prototype.toString()")}} 方法。该方法实现如下:(假定 ObjectString 没有被更改):

                                    Error.prototype.toString = function()
                                     {
                                    @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/toString
                                       return name + ": " + msg;
                                     };
                                     
                                    -

                                    示例

                                    +

                                    示例

                                    var e = new Error("fatal error");
                                     print(e.toString()); // "Error: fatal error"
                                     
                                    @@ -123,7 +123,7 @@ print(e.toString()); // "hello"
                                       
                                      
                                     
                                    -

                                    相关链接

                                    +

                                    相关链接

                                    • {{jsxref("Error.prototype.toSource()")}}
                                    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 -

                                    概览

                                    +

                                    概览

                                    废弃的 escape() 方法生成新的由十六进制转义序列替换的字符串. 使用 {{jsxref("Global_Objects/encodeURI", "encodeURI")}} 或 {{jsxref("Global_Objects/encodeURIComponent", "encodeURIComponent")}} 代替.

                                    -

                                    语法

                                    +

                                    语法

                                    escape(str)
                                    -

                                    参数

                                    +

                                    参数

                                    str
                                    待编码的字符串.
                                    -

                                    描述

                                    +

                                    描述

                                    escape 函数是全局对象的属性. 特色字符如: @*_+-./ 被排除在外.

                                    @@ -118,7 +118,7 @@ escape("@*_+-./"); // "@*_+-./"
                                    -

                                    其他链接

                                    +

                                    其他链接

                                    • {{jsxref("Global_Objects/encodeURI", "encodeURI")}}
                                    • 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()); (0, eval)('x + y'); // 另一个间接调用的例子 ​}
                                  -

                                  永远不要使用 eval

                                  +

                                  永远不要使用 eval

                                  eval() 是一个危险的函数, 它使用与调用者相同的权限执行代码。如果你用 eval() 运行的字符串代码被恶意方(不怀好意的人)修改,您最终可能会在您的网页/扩展程序的权限下,在用户计算机上运行恶意代码。更重要的是,第三方代码可以看到某一个 eval() 被调用时的作用域,这也有可能导致一些不同方式的攻击。相似的 {{jsxref("Global_Objects/Function", "Function")}} 就不容易被攻击。

                                  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

                                  本对象代表了一个关于 eval 函数的错误.此异常不再会被JavaScript抛出,但是EvalError对象仍然保持兼容性.

                                  -

                                  语法

                                  +

                                  语法

                                  new EvalError([message[, fileName[, lineNumber]]])
                                  -

                                  参数

                                  +

                                  参数

                                  message
                                  @@ -28,14 +28,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/EvalError
                                  可选参数.代码中导致异常的代码的行号.
                                  -

                                  属性

                                  +

                                  属性

                                  prototype
                                  允许向EvalError对象中添加自定义属性.
                                  -

                                  方法

                                  +

                                  方法

                                  全局的EvalError对象本身不包含任何方法, 然而它通过原型链继承了一些方法.

                                  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]]);
                                用可变数量的参数创建一个新的Float32Array。 参见 {{jsxref("Array.of()")}}。
                    -

                    Float32Array 属性

                    +

                    Float32Array 属性

                    所有的Float32Array对象都继承自 {{jsxref("TypedArray.prototype", "%TypedArray%.prototype")}}。

                    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 -

                    语法

                    +

                    语法

                    func.apply(thisArg, [argsArray])
                    -

                    参数

                    +

                    参数

                    thisArg
                    @@ -34,7 +34,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply

                    调用有指定this值和参数的函数的结果。

                    -

                    描述

                    +

                    描述

                    在调用一个存在的函数时,你可以为其指定一个 this 对象。 this 指当前对象,也就是正在调用这个函数的对象。 使用 apply, 你可以只写一次这个方法然后在另一个对象中继承它,而不用在新对象中重复写该方法。

                    @@ -48,7 +48,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply

                    需要注意:Chrome 14 以及 Internet Explorer 9 仍然不接受类数组对象。如果传入类数组对象,它们会抛出异常。

                    -

                    示例

                    +

                    示例

                    用 apply 将数组各项添加到另一个数组

                    @@ -64,7 +64,7 @@ array.push.apply(array, elements); console.info(array); // ["a", "b", 0, 1, 2] -

                    使用apply和内置函数

                    +

                    使用apply和内置函数

                    对于一些需要写循环以遍历数组各项的需求,我们可以用apply完成以避免循环。

                    @@ -106,7 +106,7 @@ for (var i = 0; i < numbers.length; i++) { var min = minOfArray([5, 6, 2, 3, 7]); -

                    使用apply来链接构造器

                    +

                    使用apply来链接构造器

                    你可以使用apply来链接一个对象构造器,类似于Java。在接下来的例子中我们会创建一个全局Function 对象的construct方法 ,来使你能够在构造器中使用一个类数组对象而非参数列表。

                    @@ -204,7 +204,7 @@ console.log(myInstance.constructor);              // logs "MyConstructor"

                    {{Compat("javascript.builtins.Function.apply")}}

                    -

                    相关链接

                    +

                    相关链接

                    • {{jsxref("Functions_and_function_scope/arguments", "arguments ")}} object
                    • 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

                      {{Compat("javascript.builtins.Function.call")}}

                      -

                      相关链接

                      +

                      相关链接

                      • {{jsxref("Function.prototype.bind()")}}
                      • 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 ---
                        {{JSRef("Global_Objects", "Function")}} {{non-standard_header}}
                        -

                        概述

                        +

                        概述

                        返回调用指定函数的函数.

                        该属性不是ECMA-262第3版标准的一部分.不过, SpiderMonkey (Mozilla的JavaScript引擎) (查看{{ Bug("65683") }}), V8 (Chrome的JavaScript引擎) 和 JScript(IE的ECMAScript实现)都已经支持了它.

                        -

                        描述

                        +

                        描述

                        如果一个函数f是在全局作用域内被调用的,则f.caller为null,相反,如果一个函数是在另外一个函数作用域内被调用的,则f.caller指向调用它的那个函数.

                        该属性的常用形式arguments.callee.caller替代了被废弃的 arguments.caller.

                        -

                        备注

                        +

                        备注

                        注意,在使用递归调用时, 你不能使用此属性来重现出调用栈.请考虑以下代码:

                        @@ -50,9 +50,9 @@ while (f) {

                        有一个特殊属性 __caller__, 可以返回调用当前函数的函数的活动对象(可以用来重现出整个调用栈), 但由于安全原因的考虑,该属性已被删除.

                        -

                        例子

                        +

                        例子

                        -

                        例子: 检测一个函数的caller属性的值

                        +

                        例子: 检测一个函数的caller属性的值

                        下例用来得出一个函数是被谁调用的.

                        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
                        {{js_property_attributes(0,0,1)}}
                        -

                        描述

                        +

                        描述

                        length 是函数对象的一个属性值,指该函数期望传入的参数数量,即形参的个数。

                        @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/length

                         {{jsxref("Function.prototype")}}  对象的 length 属性值为 0 。

                        -

                        示例

                        +

                        示例

                        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
                         
                        {{JSRef("Global_Objects", "Function")}} {{non-standard_header}}
                        -

                        概述

                        +

                        概述

                        返回函数的源代码的字符串表示.

                        -

                        语法

                        +

                        语法

                        function.toSource();
                         Function.toSource();
                         
                        -

                        参数

                        +

                        参数

                        -

                        描述

                        +

                        描述

                        toSource方法返回下面的值:

                        @@ -41,7 +41,7 @@ Function.toSource();

                        该方法通常在引擎内部调用.你可以在调试的时候用该方法开查看一个函数的源代码.

                        -

                        相关链接

                        +

                        相关链接

                        • toString
                        • 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
                          {{EmbedInteractiveExample("pages/js/function-tostring.html")}}
                          -

                          语法

                          +

                          语法

                          function.toString()
                          @@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/toString

                          表示函数源代码的一个字符串

                          -

                          描述

                          +

                          描述

                          {{jsxref("Function")}}对象覆盖了从{{jsxref("Object")}}继承来的{{jsxref("Object.prototype.toString", "toString")}} 方法。对于用户定义的 {{jsxref("Function")}} 对象,toString方法返回一个字符串,其中包含用于定义函数的源文本段。

                          @@ -223,7 +223,7 @@ Function("a", "b")
                      • 从Firefox 38开始,Function.prototype.toString() 会对 {{jsxref("Proxy")}} 对象抛出异常 ({{bug(1100936)}})。
                      -

                      相关链接

                      +

                      相关链接

                      • {{jsxref("Object.prototype.toString()")}}
                      • 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

                        {{Compat("javascript.builtins.Generator")}}

                        -

                        相关链接

                        +

                        相关链接

                        Legacy generators

                        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

                        next() 方法返回一个包含属性 donevalue 的对象。该方法也可以通过接受一个参数用以向生成器传值。

                        -

                        语法

                        +

                        语法

                        gen.next(value)
                        -

                        参数

                        +

                        参数

                        value
                        @@ -43,7 +43,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Generator/next

                        示例

                        -

                        使用 next()方法

                        +

                        使用 next()方法

                        下面的例子展示了一个简单的生成器, 以及调用 next 后方法的返回值:

                        @@ -79,7 +79,7 @@ g.next(2); // "{ value: null, done: false }" -

                        规范

                        +

                        规范

                        @@ -101,7 +101,7 @@ g.next(2);
                        -

                        浏览器兼容性

                        +

                        浏览器兼容性

                        {{CompatibilityTable}}
                        @@ -157,7 +157,7 @@ g.next(2); -

                        相关链接

                        +

                        相关链接

                        • function*
                        • 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

                          return() 方法返回给定的值并结束生成器。

                          -

                          语法

                          +

                          语法

                          gen.return(value)
                          -

                          参数

                          +

                          参数

                          value
                          @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Generator/return

                          示例

                          -

                          使用 return()

                          +

                          使用 return()

                          以下例子展示了一个简单的生成器和 return 方法的使用.

                          @@ -64,7 +64,7 @@ g.next(); // { value: undefined, done: true } g.return(); // { value: undefined, done: true } g.return(1); // { value: 1, done: true } -

                          规范

                          +

                          规范

                          @@ -86,13 +86,13 @@ g.return(1); // { value: 1, done: true }
                          -

                          浏览器兼容性

                          +

                          浏览器兼容性

                          {{Compat("javascript.builtins.Generator.return")}}

                          -

                          相关链接

                          +

                          相关链接

                          • function*
                          • 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

                            throw() 方法用来向生成器抛出异常,并恢复生成器的执行,返回带有 donevalue 两个属性的对象。

                            -

                            语法

                            +

                            语法

                            gen.throw(exception)
                            @@ -42,7 +42,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Generator/throw

                            示例

                            -

                            使用 throw()

                            +

                            使用 throw()

                            下面的例子展示了一个简单的生成器并使用 throw方法向该生成器抛出一个异常,该异常通常可以通过 try...catch 块进行捕获.

                            @@ -61,7 +61,7 @@ g.next(); // { value: 42, done: false } g.throw(new Error("Something went wrong")); // "Error caught!" -

                            规范

                            +

                            规范

                            @@ -83,7 +83,7 @@ g.throw(new Error("Something went wrong")); // "Error caught!"
                            -

                            浏览器兼容性

                            +

                            浏览器兼容性

                            {{CompatibilityTable}}
                            @@ -135,7 +135,7 @@ g.throw(new Error("Something went wrong")); // "Error caught!" -

                            相关链接

                            +

                            相关链接

                            • function*
                            • 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
                              Object.getPrototypeOf(function*(){}).constructor
                               
                              -

                              语法

                              +

                              语法

                              new GeneratorFunction ([arg1[, arg2[, ...argN]],] functionBody)
                              -

                              参数

                              +

                              参数

                              arg1, arg2, ... argN
                              @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/GeneratorFunction
                              一个包含多条表示JavaScript函数体语句的字符串。
                              -

                              描述

                              +

                              描述

                              当创建函数时,将使用GeneratorFunction构造函数创建的{{jsxref("Statements/function*", "生成器函数")}}对象进行解析。这比使用{{jsxref("Statements/function*", "function* 表达式")}} 声明生成器函数效率更低,并且在代码中调用它,因为这些函数与其余的代码一起被解析。

                              @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/GeneratorFunction

                              GeneratorFunction构造函数调用为函数(不使用new运算符)与将其作为构造函数调用的效果相同。

                              -

                              属性

                              +

                              属性

                              GeneratorFunction.length
                              @@ -59,11 +59,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/GeneratorFunction
                              {{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/GeneratorFunction/prototype', 'Properties')}}
                              -

                              GeneratorFunction 实例

                              +

                              GeneratorFunction 实例

                              GeneratorFunction实例从{{jsxref("GeneratorFunction.prototype")}}继承方法和属性。与所有构造函数一样,你可以更改构造函数的原型对象以对所有GeneratorFunction实例进行更改。

                              -

                              示例

                              +

                              示例

                              GeneratorFunction构造函数创建一个生成器函数

                              @@ -99,7 +99,7 @@ console.log(iterator.next().value); // 20

                              {{Compat("javascript.builtins.GeneratorFunction")}}

                              -

                              相关链接

                              +

                              相关链接

                              • {{jsxref("Statements/function*", "function* function")}}
                              • 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

                                {{EmbedInteractiveExample("pages/js/globalprops-infinity.html")}}

                                -

                                描述

                                +

                                描述

                                Infinity全局对象global object)的一个属性,即它是一个全局变量。

                                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
                                isFinite(testValue)
                                -

                                参数

                                +

                                参数

                                testValue
                                用于检测有限性(finiteness)的值。
                                -

                                描述

                                +

                                描述

                                isFinite 是全局的方法,不与任何对象有关系。
                                @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isFinite

                                你可以用这个方法来判定一个数字是否是有限数字。isFinite 方法检测它参数的数值。如果参数是 NaN,正无穷大或者负无穷大,会返回false,其他返回 true

                                -

                                示例

                                +

                                示例

                                isFinite(Infinity);  // false
                                 isFinite(NaN);       // false
                                @@ -97,7 +97,7 @@ isFinite("0");       // true, 在更强壮的Number.isFinite('0')中将会得到
                                 
                                 

                                {{Compat("javascript.builtins.isFinite")}}

                                -

                                相关链接

                                +

                                相关链接

                                • {{jsxref("Number.isFinite()")}}
                                • 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

                                  {{EmbedInteractiveExample("pages/js/globalprops-isnan.html")}}

                                  -

                                  语法

                                  +

                                  语法

                                  isNaN(value)
                                  -

                                  参数

                                  +

                                  参数

                                  value
                                  @@ -28,13 +28,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isNaN

                                  如果给定值为 {{jsxref("NaN")}}则返回值为true;否则为false

                                  -

                                  描述

                                  +

                                  描述

                                  -

                                  isNaN 函数的必要性

                                  +

                                  isNaN 函数的必要性

                                  与 JavaScript 中其他的值不同,{{jsxref("Global_Objects/NaN", "NaN")}}不能通过相等操作符(== 和 ===)来判断 ,因为 NaN == NaNNaN === NaN 都会返回 false。 因此,isNaN 就很有必要了。

                                  -

                                  NaN值的产生

                                  +

                                  NaN值的产生

                                  当算术运算返回一个未定义的或无法表示的值时,NaN就产生了。但是,NaN并不一定用于表示某些值超出表示范围的情况。将某些不能强制转换为数值的非数值转换为数值的时候,也会得到NaN

                                  @@ -53,7 +53,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isNaN return n !== n; };
                                -

                                示例

                                +

                                示例

                                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
                                 
                                 

                                JSON对象包含两个方法: 用于解析 JavaScript Object Notation  ({{glossary("JSON")}}) 的 parse() 方法,以及将对象/值转换为 JSON字符串的 stringify() 方法。除了这两个方法, JSON这个对象本身并没有其他作用,也不能被调用或者作为构造函数调用。

                                -

                                描述

                                +

                                描述

                                -

                                JavaScript Object Notation

                                +

                                JavaScript Object Notation

                                JSON 是一种语法,用来序列化对象、数组、数值、字符串、布尔值和 {{jsxref("null")}} 。它基于 JavaScript 语法,但与之不同:JavaScript不是JSON,JSON也不是JavaScript。参考 JSON:并不是JavaScript 的子集

                                @@ -106,7 +106,7 @@ ArrayElements = JSON

                                JSONNumber(数字内部不允许包含空格)或JSONString(字符串内部的空格被解释为相应的字符,否则就有问题了)之外的任何位置可以有多余的空白字符。JSON只支持这些空白字符: 制表符(U+0009),回车(U+000D),换行(U+000A)以及空格(U+0020)。

                                -

                                方法

                                +

                                方法

                                {{jsxref("JSON.parse()")}}
                                @@ -115,7 +115,7 @@ ArrayElements = JSON
                                返回与指定值对应的JSON字符串,可以通过额外的参数, 控制仅包含某些属性, 或者以自定义方法来替换某些key对应的属性值。
                                -

                                Polyfill

                                +

                                Polyfill

                                JSON对象可能不被老版本的浏览器支持。可以将下面的代码放到JS脚本最开始的位置,这样就可以在没有原生支持 JSON 对象的浏览器(如IE6)中使用 JSON对象。

                                @@ -163,7 +163,7 @@ ArrayElements = JSON

                                业界更专业, 更强大的JSON对象 polyfills 是 JSON2 和 JSON3

                                -

                                规范

                                +

                                规范

                                @@ -190,11 +190,11 @@ ArrayElements = JSON
                                -

                                浏览器兼容性

                                +

                                浏览器兼容性

                                {{Compat("javascript.builtins.JSON")}}

                                -

                                相关链接

                                +

                                相关链接

                                • {{jsxref("Date.prototype.toJSON()")}}
                                • 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

                                  {{EmbedInteractiveExample("pages/js/json-stringify.html")}}

                                  -

                                  语法

                                  +

                                  语法

                                  JSON.stringify(value[, replacer [, space]])
                                   
                                  -

                                  参数

                                  +

                                  参数

                                  value
                                  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

                                  Math.abs(x)=|x|={xifx0-xifx<0{\mathtt{\operatorname{Math.abs}(x)}} = {|x|} = \begin{cases} x & \text{if} \quad x \geq 0 \\ -x & \text{if} \quad x < 0 \end{cases}

                                  -

                                  语法

                                  +

                                  语法

                                  Math.abs(x);
                                  -

                                  参数

                                  +

                                  参数

                                  x
                                  一个数值
                                  -

                                  说明

                                  +

                                  说明

                                  由于 Math.abs()  Math 中的一个静态方法,你应该通过 Math.abs() 调用。(Math 不是构造器)

                                  -

                                  示例

                                  +

                                  示例

                                  -

                                  Math.abs()函数的行为

                                  +

                                  Math.abs()函数的行为

                                  传入一个非数字形式的字符串或者 undefined/empty 变量,将返回 NaN。传入 null 将返回 0。

                                  @@ -115,7 +115,7 @@ Math.abs(); // NaN
                                -

                                相关链接

                                +

                                相关链接

                                • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                • 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 ---
                                  {{JSRef("Global_Objects", "Math")}}
                                  -

                                  概述

                                  +

                                  概述

                                  Math.acos() 返回一个数的反余弦值(单位为弧度),即:

                                  x[-1;1],Math.acos(x)=arccos(x)= the unique y[0;π]such thatcos(y)=x\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

                                  -

                                  语法

                                  +

                                  语法

                                  Math.acos(x) 
                                  -

                                  参数

                                  +

                                  参数

                                  x
                                  一个数值
                                  -

                                  描述

                                  +

                                  描述

                                  acos 方法以 -1 到 1 的一个数为参数,返回一个 0 到 pi (弧度)的数值。如果传入的参数值超出了限定的范围,将返回 NaN

                                  由于 acosMath 的静态方法,所以应该像这样使用:Math.acos(),而不是作为你创建的 Math 实例的属性(Math 不是一个构造函数)。

                                  -

                                  示例

                                  -

                                  例子:使用 Math.acos

                                  +

                                  示例

                                  +

                                  例子:使用 Math.acos

                                  Math.acos(-2);  // NaN
                                   Math.acos(-1);  // 3.141592653589793
                                   Math.acos(0);   // 1.5707963267948966
                                  @@ -103,7 +103,7 @@ Math.acos(2);   // NaN
                                     
                                    
                                   
                                  -

                                  相关链接

                                  +

                                  相关链接

                                  • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                  • {{jsxref("Math.asin()")}}
                                  • 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 ---
                                    {{JSRef("Global_Objects", "Math")}}
                                    -

                                    概述

                                    +

                                    概述

                                    Math.asin() 方法返回一个数值的反正弦(单位为弧度),即:

                                    x[-1;1],Math.asin(x)=arcsin(x)= the unique y[-π2;π2]such thatsin(y)=x\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

                                    -

                                    语法

                                    +

                                    语法

                                    Math.asin(x)
                                    -

                                    参数

                                    +

                                    参数

                                    x
                                    一个数值
                                    -

                                    描述

                                    +

                                    描述

                                    asin 方法接受 -1 到 1 之间的数值作为参数,返回一个介于 -π2-\frac{\pi}{2} 到 π2\frac{\pi}{2} 弧度的数值。如果接受的参数值超出范围,则返回 NaN

                                    由于 asinMath 的静态方法,所有应该像这样使用:Math.asin(),而不是作为你创建的 Math 实例的方法。

                                    -

                                    示例

                                    -

                                    例子:使用 Math.asin()

                                    +

                                    示例

                                    +

                                    例子:使用 Math.asin()

                                    Math.asin(-2);  // NaN
                                     Math.asin(-1);  // -1.5707963267948966 (-pi/2)
                                     Math.asin(0);   // 0
                                    @@ -102,7 +102,7 @@ Math.asin(2);   // NaN
                                    -

                                    相关链接

                                    +

                                    相关链接

                                    • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                    • {{jsxref("Math.acos()")}}
                                    • 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 ---
                                      {{JSRef("Global_Objects", "Math")}}
                                      -

                                      概述

                                      +

                                      概述

                                      Math.atan() 函数返回一个数值的反正切(以弧度为单位),即:

                                      Math.atan(x)=arctan(x)= the unique y[-π2;π2]such thattan(y)=x\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

                                      -

                                      语法

                                      +

                                      语法

                                      Math.atan(x)
                                      -

                                      参数

                                      +

                                      参数

                                      x
                                      一个数值
                                      -

                                      描述

                                      +

                                      描述

                                      atan 返回一个 -π2-\frac{\pi}{2} 到 π2\frac{\pi}{2} 弧度之间的数值。

                                      由于 atanMath 的静态方法,所以应该像这样使用:Math.atan(),而不是作为你创建的 Math 实例的方法。

                                      -

                                      示例

                                      -

                                      例子:使用 Math.atan

                                      +

                                      示例

                                      +

                                      例子:使用 Math.atan

                                      Math.atan(1);  // 0.7853981633974483
                                       Math.atan(0);  // 0
                                       
                                      @@ -98,7 +98,7 @@ Math.atan(0); // 0 -

                                      相关链接

                                      +

                                      相关链接

                                      • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                      • {{jsxref("Math.acos()")}}
                                      • 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 ---
                                        {{JSRef("Global_Objects", "Math")}}
                                        -

                                        概述

                                        +

                                        概述

                                        Math.atan2() 返回从原点(0,0)到(x,y)点的线段与x轴正方向之间的平面角度(弧度值),也就是Math.atan2(y,x)

                                        -

                                        语法

                                        +

                                        语法

                                        Math.atan2(y, x) 
                                        -

                                        参数

                                        +

                                        参数

                                        y, x
                                        数值
                                        -

                                        描述

                                        +

                                        描述

                                        atan2 方法返回一个 -pi 到 pi 之间的数值,表示点 (x, y) 对应的偏移角度。这是一个逆时针角度,以弧度为单位,正X轴和点 (x, y) 与原点连线 之间。注意此函数接受的参数:先传递 y 坐标,然后是 x 坐标。

                                        @@ -28,9 +28,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/atan2

                                        由于 atan2Math 的静态方法,所以应该像这样使用:Math.atan2(),而不是作为你创建的 Math 实例的方法。

                                        -

                                        示例

                                        +

                                        示例

                                        -

                                        例子:使用 Math.atan2

                                        +

                                        例子:使用 Math.atan2

                                        Math.atan2(90, 15) // 1.4056476493802699
                                         Math.atan2(15, 90) // 0.16514867741462683
                                        @@ -127,7 +127,7 @@ Math.atan2(15, 90) // 0.16514867741462683
                                         
                                         
                                         
                                        -

                                        相关链接

                                        +

                                        相关链接

                                        • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                        • 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 ---
                                          {{JSRef("Global_Objects", "Math")}}
                                          -

                                          概述

                                          +

                                          概述

                                          Math.cbrt() 函数返回任意数字的立方根.

                                          -

                                          语法

                                          +

                                          语法

                                          Math.cbrt(x)
                                          -

                                          参数

                                          +

                                          参数

                                          x
                                          @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/cbrt -

                                          描述

                                          +

                                          描述

                                          该方法为Math的静态方法,因此请直接通过Math.cbrt()方式调用.

                                          @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/cbrt

                                          cbrt 是 "cube root" 的缩写, 意思是立方根.

                                          -

                                          示例

                                          +

                                          示例

                                          使用 Math.cbrt()

                                          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 ---
                                          {{JSRef("Global_Objects", "Math")}}
                                          -

                                          概述

                                          +

                                          概述

                                          Math.clz32() 函数返回一个数字在转换成 32 无符号整形数字的二进制形式后, 开头的 0 的个数, 比如 1000000 转换成 32 位无符号整形数字的二进制形式后是 00000000000011110100001001000000, 开头的 0 的个数是 12 个, 则 Math.clz32(1000000) 返回 12.

                                          -

                                          语法

                                          +

                                          语法

                                          Math.clz32 (x)
                                           
                                          -

                                          参数

                                          +

                                          参数

                                          x
                                          @@ -45,7 +45,7 @@ Math.clz32(true) // 31 Math.clz32(3.5) // 30
                                        -

                                        计算前导1的个数

                                        +

                                        计算前导1的个数

                                        目前javascript尚未提供Math.clon函数来计算前导1的个数(之所以叫“clon”而非“clo”,是因为“clo”与“clz”太过相似,特别对那些母语不是英语的人来说),但是你可以通过将一个数取反并将其作为Math.clz32的参数来实现clon函数。其中的原理非常简单,因为对1取反是0,反之亦然,所以用Math.clz32计算前导0的个数就变成计算前导1的个数。

                                        @@ -122,7 +122,7 @@ function ctron(integer){ // 计算尾随1个数 var ctrz = countTrailsMethods.a; var ctron = countTrailsMethods.b;
                                  -

                                  Polyfill

                                  +

                                  Polyfill

                                  这个polyfill效率最高。

                                  @@ -157,7 +157,7 @@ var ctron = countTrailsMethods.b;

                                  {{Compat("javascript.builtins.Math.clz32")}}

                                  -

                                  相关链接

                                  +

                                  相关链接

                                  • {{jsxref("Math")}}
                                  • 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 ---
                                    {{JSRef("Global_Objects", "Math")}}
                                    -

                                    概述

                                    +

                                    概述

                                    Math.cos() 函数返回一个数值的余弦值。

                                    -

                                    语法

                                    +

                                    语法

                                    Math.cos(x)
                                    -

                                    参数

                                    +

                                    参数

                                    x
                                    一个以弧度为单位的数值。
                                    -

                                    描述

                                    +

                                    描述

                                    cos 方法返回一个 -1 到 1 之间的数值,表示角度(单位:弧度)的余弦值。

                                    由于 cosMath 的静态方法,所以应该像这样使用:Math.cos(),而不是作为你创建的 Math 实例的方法。

                                    -

                                    示例

                                    -

                                    例子:使用 Math.cos

                                    +

                                    示例

                                    +

                                    例子:使用 Math.cos

                                    Math.cos(0);           // 1
                                     Math.cos(1);           // 0.5403023058681398
                                     
                                    @@ -100,7 +100,7 @@ Math.cos(2 * Math.PI); // 1
                                       
                                      
                                     
                                    -

                                    相关链接

                                    +

                                    相关链接

                                    • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                    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 ---
                                    {{JSRef("Global_Objects", "Math")}}
                                    -

                                    概述

                                    +

                                    概述

                                    Math.E 属性表示自然对数的底数(或称为基数),e,约等于 2.718。

                                    Math.E=e2.718\mathtt{\mi{Math.E}} = e \approx 2.718

                                    {{js_property_attributes(0,0,0)}}
                                    -

                                    描述

                                    +

                                    描述

                                    由于 EMath 对象的静态属性,所以应该像这样使用:Math.E,而不是作为你创建的 Math 实例对象的属性(Math 不是构造函数)。

                                    -

                                    示例

                                    -

                                    例子:使用 Math.E

                                    +

                                    示例

                                    +

                                    例子:使用 Math.E

                                    下面的函数返回 e:

                                    function getNapier() {
                                        return Math.E
                                    @@ -93,7 +93,7 @@ getNapier() // 2.718281828459045
                                    -

                                    相关链接

                                    +

                                    相关链接

                                    • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                    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 ---
                                    {{JSRef("Global_Objects", "Math")}}
                                    -

                                    概述

                                    +

                                    概述

                                    Math.exp() 函数返回 exx 表示参数,e欧拉常数(Euler's constant),自然对数的底数。

                                    -

                                    语法

                                    +

                                    语法

                                    Math.exp(x)
                                    -

                                    参数

                                    +

                                    参数

                                    x
                                    一个数值
                                    -

                                    描述

                                    +

                                    描述

                                    由于 expMath 的静态方法,所以应该像这样使用:Math.exp(),而不是作为你创建的 Math 实例的方法。

                                    -

                                    示例

                                    -

                                    例子:使用 Math.exp

                                    +

                                    示例

                                    +

                                    例子:使用 Math.exp

                                    Math.exp(-1); // 0.36787944117144233
                                     Math.exp(0);  // 1
                                     Math.exp(1);  // 2.718281828459045
                                    @@ -96,7 +96,7 @@ Math.exp(1); // 2.718281828459045
                                    -

                                    相关链接

                                    +

                                    相关链接

                                    • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                    • {{jsxref("Math.E")}}
                                    • 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 ---
                                      {{JSRef("Global_Objects", "Math")}}
                                      -

                                      概述

                                      +

                                      概述

                                      Math.expm1() 函数返回 Ex - 1, 其中 x 是该函数的参数, E 是自然对数的底数 2.718281828459045.

                                      -

                                      语法

                                      +

                                      语法

                                      Math.expm1(x)
                                      -

                                      参数

                                      +

                                      参数

                                      x
                                      任意数字.
                                      -

                                      描述

                                      +

                                      描述

                                      参数 x 会被自动类型转换成 number 类型.

                                      expm1 是 "exponent minus 1" 的缩写.

                                      -

                                      示例

                                      +

                                      示例

                                      Math.expm1(1)     // 1.7182818284590453
                                       Math.expm1(-38)   // -1
                                      @@ -112,7 +112,7 @@ Math.expm1("foo") // NaN
                                       
                                       
                                       
                                      -

                                      相关链接

                                      +

                                      相关链接

                                      • {{jsxref("Global_Objects/Math", "Math")}} 对象.
                                      • 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

                                        Note:  可以理解 Math.floor()为向下取整

                                        -

                                        语法

                                        +

                                        语法

                                        Math.floor(x) 
                                        -

                                        参数

                                        +

                                        参数

                                        x
                                        @@ -31,13 +31,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/floor
                                        -

                                        描述

                                        +

                                        描述

                                        由于 floorMath 的一个静态方法,你总是应该像这样使用它 Math.floor(),而不是作为你创建的一个Math对象的一种方法(Math不是一个构造函数)。

                                        -

                                        示例

                                        +

                                        示例

                                        -

                                        例子:使用 Math.floor

                                        +

                                        例子:使用 Math.floor

                                        Math.floor( 45.95);
                                         // 45
                                        @@ -52,7 +52,7 @@ Math.floor(-45.95);
                                         
                                         
                                        -

                                        例子:十进制调整

                                        +

                                        例子:十进制调整

                                        // Closure
                                         (function(){
                                        @@ -210,7 +210,7 @@ Math.ceil10(-59, 1); // -50
                                         
                                         
                                         
                                        -

                                        相关链接

                                        +

                                        相关链接

                                        • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                        • 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 ---
                                          {{JSRef("Global_Objects", "Math")}}
                                          -

                                          概述

                                          +

                                          概述

                                          Math.fround() 可以将任意的数字转换为离它最近的单精度浮点数形式的数字。

                                          -

                                          语法

                                          +

                                          语法

                                          Math.fround(doubleFloat)
                                          -

                                          参数

                                          +

                                          参数

                                          doubleFloat
                                          一个 {{jsxref("Number")}}。若参数为非数字类型,则会被转投成数字。无法转换时,设置成{{jsxref("NaN")}}。
                                          -

                                          返回值

                                          +

                                          返回值

                                          指定数字最接近的32位单精度浮点数表示。

                                          -

                                          描述

                                          +

                                          描述

                                          JavaScript 内部使用64位的双浮点数字,支持很高的精度。但是,有时你需要用32位浮点数字,比如你从一个{{jsxref("Float32Array")}} 读取值时。这时会产生混乱:检查一个64位浮点数和一个32位浮点数是否相等会失败,即使二个数字几乎一模一样。

                                          @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/fround

                                          因为fround()Math 的静态方法,你必须通过 Math.fround() 来使用,而不是调用你创建的Math 对象的一个实例方法(Math不是一个构造函数)。

                                          -

                                          示例

                                          +

                                          示例

                                          使用 Math.fround()

                                          @@ -70,7 +70,7 @@ function equal(v1, v2) { equal(0.1 + 0.2, 0.3); //true
                                        -

                                        Polyfill

                                        +

                                        Polyfill

                                        下面的函数可以模拟这个 API,前提是浏览器必须已经支持 {{jsxref("Float32Array")}}:

                                        @@ -80,7 +80,7 @@ equal(0.1 + 0.2, 0.3); //true }; })(new Float32Array(1));
                                      -

                                      规范

                                      +

                                      规范

                                      @@ -95,7 +95,7 @@ equal(0.1 + 0.2, 0.3); //true
                                      -

                                      浏览器兼容性

                                      +

                                      浏览器兼容性

                                      {{CompatibilityTable}}
                                      @@ -147,7 +147,7 @@ equal(0.1 + 0.2, 0.3); //true -

                                      相关链接

                                      +

                                      相关链接

                                      • {{jsxref("Math.round()")}}
                                      • 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 -

                                        语法

                                        +

                                        语法

                                        Math.hypot([value1[,value2, ...]]) 
                                        -

                                        参数

                                        +

                                        参数

                                        value1, value2, ...
                                        @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/hypot

                                        将所提供的参数求平方和后开平方根。如果有参数不能转换为数字,则返回 {{jsxref("NaN")}}。

                                        -

                                        描述

                                        +

                                        描述

                                        计算直角三角形的斜边,或复数的幅值时可以使用函数 Math.sqrt(v1*v1 + v2*v2) ,其中 v1 和 v2 是三角形的两个直角边或复数的实部和虚部。如果想计算更多维度,那么只需要在后面添加更多的数的平方就可以了,比如 Math.sqrt(v1*v1 + v2*v2 + v3*v3 + v4*v4)

                                        @@ -48,7 +48,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/hypot

                                        如果只传入一个参数,  Math.hypot(x) 等同于 Math.abs(x).

                                        -

                                        示例

                                        +

                                        示例

                                        Using Math.hypot()

                                        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
                                        var product = Math.imul(a, b)
                                        -

                                        参数

                                        +

                                        参数

                                        a
                                        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 ---
                                        {{JSRef("Global_Objects", "Math")}}
                                        -

                                        概述

                                        +

                                        概述

                                        Math.LN10 属性表示 10 的自然对数,约为 2.302:

                                        Math.LN10=ln(10)2.302\mathtt{\mi{Math.LN10}} = \ln(10) \approx 2.302

                                        {{js_property_attributes(0,0,0)}}
                                        -

                                        描述

                                        +

                                        描述

                                        由于 LN10Math 的静态属性,所以应该像这样使用:Math.LN10,而不是作为你创建的 Math 实例的属性(Math 不是构造函数)。

                                        -

                                        示例

                                        -

                                        例子:使用 Math.LN10

                                        +

                                        示例

                                        +

                                        例子:使用 Math.LN10

                                        下面的函数返回 10 的自然对数:

                                        function getNatLog10() {
                                            return Math.LN10
                                        @@ -93,7 +93,7 @@ getNatLog10() // 2.302585092994046
                                        -

                                        相关链接

                                        +

                                        相关链接

                                        • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                        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 ---
                                        {{JSRef("Global_Objects", "Math")}}
                                        -

                                        概述

                                        +

                                        概述

                                        Math.LN2 属性表示 2 的自然对数,约为 0.693:

                                        Math.LN2=ln(2)0.693\mathtt{\mi{Math.LN2}} = \ln(2) \approx 0.693

                                        {{js_property_attributes(0,0,0)}}
                                        -

                                        描述

                                        +

                                        描述

                                        由于 LN2Math 的静态属性,所以应该像这样使用:Math.LN2,而不是作为你创建的 Math 实例的属性(Math 不是构造函数)。

                                        -

                                        示例

                                        -

                                        例子:使用 Math.LN2

                                        +

                                        示例

                                        +

                                        例子:使用 Math.LN2

                                        下面的函数返回 2 的自然对数:

                                        function getNatLog2() {
                                            return Math.LN2
                                        @@ -93,7 +93,7 @@ getNatLog2() // 0.6931471805599453
                                        -

                                        相关链接

                                        +

                                        相关链接

                                        • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                        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 ---

                                        {{JSRef("Global_Objects", "Math")}}

                                        -

                                        概述

                                        +

                                        概述

                                        Math.log() 函数返回一个数的自然对数,即:

                                        x>0,Math.log(x)=ln(x)=the uniqueysuch thatey=x\forall x > 0, \mathtt{\operatorname{Math.log}(x)} = \ln(x) = \text{the unique} \; y \; \text{such that} \; e^y = x

                                        -

                                        语法

                                        +

                                        语法

                                        Math.log(x)
                                        -

                                        参数

                                        +

                                        参数

                                        x
                                        一个数字.
                                        -

                                        描述

                                        +

                                        描述

                                        如果指定的 number 为负数,则返回值为 NaN

                                        @@ -30,7 +30,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/log

                                        示例

                                        -

                                        例子1:使用Math.log

                                        +

                                        例子1:使用Math.log

                                        下面的函数返回指定变量的自然对数:

                                        @@ -128,7 +128,7 @@ Math.log(10); // 2.302585092994046 -

                                        相关链接

                                        +

                                        相关链接

                                        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
                                        {{JSRef("Global_Objects", "Math")}}
                                        -

                                        概述

                                        +

                                        概述

                                        Math.log10() 函数返回一个数字以 10 为底的对数.

                                        -

                                        语法

                                        +

                                        语法

                                        Math.log10(x)
                                        -

                                        参数

                                        +

                                        参数

                                        x
                                        任意数字.
                                        -

                                        描述

                                        +

                                        描述

                                        如果传入的参数小于 0, 则返回 NaN.

                                        -

                                        示例

                                        +

                                        示例

                                        Math.log10(10)   // 1
                                         Math.log10(100)  // 2
                                        @@ -106,7 +106,7 @@ Math.log10("foo")// NaN
                                         
                                         
                                         
                                        -

                                        相关链接

                                        +

                                        相关链接

                                        • {{jsxref("Global_Objects/Math", "Math")}} 对象.
                                        • 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 ---
                                          {{JSRef("Global_Objects", "Math")}}
                                          -

                                          概述

                                          +

                                          概述

                                          Math.LOG10E 属性表示以 10 为底数,e 的对数,约为 0.434:

                                          Math.LOG10E=log10(e)0.434\mathtt{\mi{Math.LOG10E}} = \log_10(e) \approx 0.434

                                          {{js_property_attributes(0,0,0)}}
                                          -

                                          描述

                                          +

                                          描述

                                          由于 LOG10EMath 的静态属性,所以应该像这样使用:Math.LOG10E,而不是作为你创建的 Math 实例的属性(Math 不是一个构造函数)。

                                          -

                                          示例

                                          -

                                          例子:使用 Math.LOG10E

                                          +

                                          示例

                                          +

                                          例子:使用 Math.LOG10E

                                          下面的函数返回以 10为底数,E的对数:

                                          function getLog10e() {
                                              return Math.LOG10E
                                          @@ -93,7 +93,7 @@ getLog10e() // 0.4342944819032518
                                          -

                                          相关链接

                                          +

                                          相关链接

                                          • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                          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
                                          {{JSRef("Global_Objects", "Math")}}
                                          -

                                          概述

                                          +

                                          概述

                                          Math.log1p() 函数返回一个数字加1后的自然对数 (底为 E), 既log(x+1).

                                          -

                                          语法

                                          +

                                          语法

                                          Math.log1p(x)
                                          -

                                          参数

                                          +

                                          参数

                                          x
                                          任意数字.
                                          -

                                          描述

                                          +

                                          描述

                                          如果参数的值小于 -1, 则返回 NaN.

                                          @@ -109,7 +109,7 @@ Math.log1p("foo") // NaN -

                                          相关链接

                                          +

                                          相关链接

                                          • {{jsxref("Global_Objects/Math", "Math")}} 对象.
                                          • 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
                                            {{JSRef("Global_Objects", "Math")}}
                                            -

                                            概述

                                            +

                                            概述

                                            Math.log2() 函数返回一个数字以 2 为底的对数.

                                            -

                                            语法

                                            +

                                            语法

                                            Math.log2(x)
                                            -

                                            参数

                                            +

                                            参数

                                            x
                                            任意数字.
                                            -

                                            描述

                                            +

                                            描述

                                            如果传入的参数小于 0, 则返回 NaN.

                                            -

                                            示例

                                            +

                                            示例

                                            Math.log2(2)     // 1
                                             Math.log2(1024)  // 10
                                            @@ -106,7 +106,7 @@ Math.log2("foo") // NaN
                                             
                                             
                                             
                                            -

                                            相关链接

                                            +

                                            相关链接

                                            • {{jsxref("Global_Objects/Math", "Math")}} 对象.
                                            • 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 ---
                                              {{JSRef("Global_Objects", "Math")}}
                                              -

                                              概述

                                              +

                                              概述

                                              Math.LOG2E 属性表示以 2 为底数,e 的对数,约为 1.442:

                                              Math.LOG2E=log2(e)1.442\mathtt{\mi{Math.LOG2E}} = \log_2(e) \approx 1.442

                                              {{js_property_attributes(0,0,0)}}
                                              -

                                              描述

                                              +

                                              描述

                                              由于 LOG2EMath 的静态属性,所以应该像这样使用:Math.LOG2E,而不是作为你创建的 Math 对象的属性(Math 不是一个构造函数)。

                                              -

                                              示例

                                              -

                                              例子:使用 Math.LOG2E

                                              +

                                              示例

                                              +

                                              例子:使用 Math.LOG2E

                                              下面的函数返回以 2 为底数,E 的对数:

                                              function getLog2e() {
                                                  return Math.LOG2E
                                              @@ -93,7 +93,7 @@ getLog2e() // 1.4426950408889634
                                              -

                                              相关链接

                                              +

                                              相关链接

                                              • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                              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

                                              {{EmbedInteractiveExample("pages/js/math-max.html")}}

                                              -

                                              语法

                                              +

                                              语法

                                              Math.max(value1[,value2, ...]) 
                                              -

                                              参数

                                              +

                                              参数

                                              value1, value2, ...
                                              @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/max

                                              返回给定的一组数字中的最大值。如果给定的参数中至少有一个参数无法被转换成数字,则会返回 {{jsxref("NaN")}}。

                                              -

                                              描述

                                              +

                                              描述

                                              由于 maxMath 的静态方法,所以应该像这样使用:Math.max(),而不是创建的 Math 实例的方法(Math 不是构造函数)。

                                              @@ -35,9 +35,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/max

                                              如果有任一参数不能被转换为数值,则结果为 {{jsxref("NaN")}}。

                                              -

                                              示例

                                              +

                                              示例

                                              -

                                              使用 Math.max()

                                              +

                                              使用 Math.max()

                                              Math.max(10, 20);   //  20
                                               Math.max(-10, -20); // -10
                                              @@ -92,7 +92,7 @@ var max = Math.max(...arr);
                                               
                                               

                                              {{Compat("javascript.builtins.Math.max")}}

                                              -

                                              相关链接

                                              +

                                              相关链接

                                              • {{jsxref("Math.min()")}}
                                              • 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

                                                Math.min() 返回零个或更多个数值的最小值。

                                                -

                                                语法

                                                +

                                                语法

                                                Math.min([value1[,value2, ...]]) 
                                                -

                                                参数

                                                +

                                                参数

                                                value1, value2, ...
                                                @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/min

                                                给定数值中最小的数。如果任一参数不能转换为数值,则返回{{jsxref("NaN")}}。

                                                -

                                                描述

                                                +

                                                描述

                                                由于 minMath 的静态方法,所以应该像这样使用:Math.min(),而不是作为你创建的 Math 实例的方法(Math 不是构造函数)。

                                                @@ -36,9 +36,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/min

                                                如果有任一参数不能被转换为数值,结果为 {{jsxref("NaN")}}。

                                                -

                                                示例

                                                +

                                                示例

                                                -

                                                使用 Math.min()

                                                +

                                                使用 Math.min()

                                                下例找出 x 和 y 的最小值,并把它赋值给 z:

                                                @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/min var z = Math.min(x, y);
                                              -

                                              使用 Math.min() 裁剪值(Clipping a value)

                                              +

                                              使用 Math.min() 裁剪值(Clipping a value)

                                              Math.min 经常用于裁剪一个值,以便使其总是小于或等于某个边界值。例如:

                                              @@ -148,7 +148,7 @@ if (x > boundary) { -

                                              相关链接

                                              +

                                              相关链接

                                              • {{jsxref("Math.max()")}}
                                              • 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 ---
                                                {{JSRef("Global_Objects", "Math")}}
                                                -

                                                概述

                                                +

                                                概述

                                                Math.PI 表示一个圆的周长与直径的比例,约为 3.14159:

                                                @@ -13,13 +13,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/PI
                                                {{js_property_attributes(0,0,0)}}
                                                -

                                                描述

                                                +

                                                描述

                                                由于 PIMath 的静态属性,所以应该像这样使用:Math.PI,而不是作为你创建的 Math 实例的属性(Math 不是构造函数)。

                                                -

                                                示例

                                                +

                                                示例

                                                -

                                                使用 Math.PI

                                                +

                                                使用 Math.PI

                                                下面的函数使用 Math.PI 计算给定半径的圆周长:

                                                @@ -108,7 +108,7 @@ calculateCircumference(1); // 6.283185307179586
                                            -

                                            相关链接

                                            +

                                            相关链接

                                            • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                            • 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

                                              {{EmbedInteractiveExample("pages/js/math-pow.html")}}

                                              -

                                              语法

                                              +

                                              语法

                                              Math.pow(base, exponent) 
                                              -

                                              参数

                                              +

                                              参数

                                              base
                                              @@ -22,13 +22,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/pow
                                              指数
                                              -

                                              描述

                                              +

                                              描述

                                              由于 pow 是 Math 的静态方法,所以应该像这样使用:Math.pow(),而不是作为你创建的 Math 对象的方法。

                                              -

                                              示例

                                              +

                                              示例

                                              -

                                              使用 Math.pow

                                              +

                                              使用 Math.pow

                                              function raisePower(x,y) {
                                                  return Math.pow(x,y)
                                              @@ -67,7 +67,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/pow
                                               
                                               

                                              {{Compat("javascript.builtins.Math.pow")}}

                                              -

                                              相关链接

                                              +

                                              相关链接

                                              • {{jsxref("Math.cbrt()")}}
                                              • 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

                                                Math.random() 不能提供像密码一样安全的随机数字。不要使用它们来处理有关安全的事情。使用Web Crypto API 来代替, 和更精确的{{domxref("RandomSource.getRandomValues()", "window.crypto.getRandomValues()")}} 方法.

                                                -

                                                语法

                                                +

                                                语法

                                                Math.random()
                                                -

                                                返回值

                                                +

                                                返回值

                                                一个浮点型伪随机数字,在0(包括0)和1(不包括)之间。

                                                -

                                                示例

                                                +

                                                示例

                                                请注意, 由于 JavaScript 中的数字是 IEEE 754 浮点数字,具有最近舍入( round-to-nearest-even)的行为, 因此以下函数的范围 (不包括Math.random() 本身) 并不准确。如果选择了非常大的边界 (253 或更高), 在极罕见的情况下会计算通常-排除(usually-excluded)的上界。(注:round-to-nearest-even采用最近舍入的去偶数舍入的方式,对.5的舍入上,采用取偶数的方式)

                                                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

                                                Math.round() 函数返回一个数字四舍五入后最接近的整数。

                                                -

                                                语法

                                                +

                                                语法

                                                Math.round(x) 
                                                -

                                                参数

                                                +

                                                参数

                                                x
                                                @@ -26,13 +26,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/round
                                                -

                                                描述

                                                +

                                                描述

                                                如果参数的小数部分大于 0.5,则舍入到相邻的绝对值更大的整数。 如果参数的小数部分小于 0.5,则舍入到相邻的绝对值更小的整数。如果参数的小数部分恰好等于0.5,则舍入到相邻的在正无穷(+∞)方向上的整数。注意,与很多其他语言中的round()函数不同,Math.round()并不总是舍入到远离0的方向(尤其是在负数的小数部分恰好等于0.5的情况下)。

                                                因为 round() 是 Math 的静态方法,你应该直接使用 Math.round(),而不是作为你创建的 Math 对象的一个实例方法来使用(Math没有构造函数)。

                                                -

                                                示例

                                                +

                                                示例

                                                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
                                                 
                                                -

                                                小数舍入

                                                +

                                                小数舍入

                                                // 闭包
                                                 (function(){
                                                @@ -203,7 +203,7 @@ round(1.005, 2);    //1.01
                                                 
                                                 
                                                 
                                                -

                                                相关链接

                                                +

                                                相关链接

                                                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

                                                Math.sign() 函数返回一个数字的符号, 指示数字是正数,负数还是零。

                                                -

                                                语法

                                                +

                                                语法

                                                Math.sign(x);
                                                -

                                                参数

                                                +

                                                参数

                                                x
                                                任意数字.
                                                -

                                                描述

                                                +

                                                描述

                                                因为 sign Math 的一个静态方法,所以你应该使用 Math.sign() ,而不是作为你创建的一个Math对象的一种方法 (Math不是一个构造函数)。

                                                @@ -34,7 +34,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/sign

                                                传入该函数的参数会被隐式转换成数字类型。

                                                -

                                                示例

                                                +

                                                示例

                                                使用Math.sign()

                                                @@ -48,7 +48,7 @@ Math.sign("foo"); // NaN Math.sign(); // NaN
                                                -

                                                Polyfill

                                                +

                                                Polyfill

                                                function sign(x) {
                                                     x = +x ;// convert to a number
                                                @@ -145,7 +145,7 @@ Math.sign();      // NaN
                                                 
                                                 
                                                 
                                                -

                                                相关链接

                                                +

                                                相关链接

                                                • {{jsxref("Global_Objects/Math", "Math")}} 对象
                                                • 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 ---
                                                  {{JSRef("Global_Objects", "Math")}}
                                                  -

                                                  概述

                                                  +

                                                  概述

                                                  Math.sin() 函数返回一个数值的正弦值。

                                                  -

                                                  语法

                                                  +

                                                  语法

                                                  Math.sin(x)
                                                  -

                                                  参数

                                                  +

                                                  参数

                                                  x
                                                  一个数值(以弧度为单位)。
                                                  -

                                                  描述

                                                  +

                                                  描述

                                                  sin 方法返回一个 -1 到 1 之间的数值,表示给定角度(单位:弧度)的正弦值。

                                                  由于 sinMath 的静态方法,所以应该像这样使用:Math.sin(),而不是作为你创建的 Math 实例的方法。

                                                  -

                                                  示例

                                                  +

                                                  示例

                                                  -

                                                  例子:使用 Math.sin

                                                  +

                                                  例子:使用 Math.sin

                                                  Math.sin(0);           // 0
                                                   Math.sin(1);           // 0.8414709848078965
                                                  @@ -68,7 +68,7 @@ Math.sin(Math.PI / 2); // 1
                                                  -

                                                  相关链接

                                                  +

                                                  相关链接

                                                  • {{jsxref("Math.acos()")}}
                                                  • 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 ---
                                                    {{JSRef("Global_Objects", "Math")}}
                                                    -

                                                    概述

                                                    +

                                                    概述

                                                     Math.sinh() 函数返回一个数字(单位为角度)的双曲正弦值.

                                                    -

                                                    语法

                                                    +

                                                    语法

                                                    Math.sinh(x)
                                                    -

                                                    参数

                                                    +

                                                    参数

                                                    x
                                                    任意数字 (单位为度).
                                                    -

                                                    描述

                                                    +

                                                    描述

                                                    双曲正弦的图像如下:

                                                    -

                                                    示例

                                                    +

                                                    示例

                                                    Math.sinh(0)      // 0
                                                     Math.sinh(1)      // 1.1752011936438014
                                                    @@ -111,7 +111,7 @@ Math.sinh("foo")  // NaN
                                                     
                                                     
                                                     
                                                    -

                                                    相关链接

                                                    +

                                                    相关链接

                                                    • {{jsxref("Math.acos()")}}
                                                    • 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

                                                      {{EmbedInteractiveExample("pages/js/math-sqrt.html")}}

                                                      -

                                                      语法

                                                      +

                                                      语法

                                                      Math.sqrt(x) 
                                                      -

                                                      参数

                                                      +

                                                      参数

                                                      x
                                                      一个数值
                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      如果参数 number 为负值,则 sqrt 返回{{jsxref("NaN")}}。

                                                      由于 sqrt 是 Math 的静态方法,所以应该像这样使用:Math.sqrt(),而不是作为你创建的 Math 实例的方法。

                                                      -

                                                      示例

                                                      +

                                                      示例

                                                      -

                                                      使用 Math.sqrt

                                                      +

                                                      使用 Math.sqrt

                                                      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
                                                       ---
                                                       
                                                      {{JSRef("Global_Objects", "Math")}}
                                                      -

                                                      概述

                                                      +

                                                      概述

                                                      Math.SQRT1_2 属性表示 1/2 的平方根,约为 0.707:

                                                      Math.SQRT1_2=12=120.707\mathtt{\mi{Math.SQRT1_2}} = \sqrt{\frac{1}{2}} = \frac{1}{\sqrt{2}} \approx 0.707

                                                      {{js_property_attributes(0,0,0)}}
                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      由于 SQRT1_2Math 对象的静态属性,所以应该像这样使用:Math.SQRT1_2,而不是作为你创建的 Math 实例的属性(Math 不是构造函数)。

                                                      -

                                                      示例

                                                      -

                                                      例子:使用 SQRT1_2

                                                      +

                                                      示例

                                                      +

                                                      例子:使用 SQRT1_2

                                                      下面的函数返回 1/2 的平方根:

                                                      function getRoot1_2() {
                                                          return Math.SQRT1_2
                                                      @@ -94,7 +94,7 @@ getRoot1_2() // 0.7071067811865476
                                                      -

                                                      相关链接

                                                      +

                                                      相关链接

                                                      • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                                      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 ---

                                                      {{JSRef("Global_Objects", "Math")}}

                                                      -

                                                      概述

                                                      +

                                                      概述

                                                      Math.SQRT2 属性表示 2 的平方根,约为 1.414:

                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      由于 SQRT2 是 Math 的静态属性,所以应该像这样使用:Math.SQRT2,而不是作为你创建的 Math 实例的属性(Math 不是构造函数)。

                                                      -

                                                      示例

                                                      -

                                                      例子:使用 Math.SQRT2

                                                      +

                                                      示例

                                                      +

                                                      例子:使用 Math.SQRT2

                                                      下面的函数返回 2 的平方根:

                                                      function getRoot2() {
                                                          return Math.SQRT2;
                                                      @@ -89,7 +89,7 @@ getRoot2(); // 1.4142135623730951
                                                      -

                                                      相关链接

                                                      +

                                                      相关链接

                                                      • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
                                                      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 ---
                                                      {{JSRef("Global_Objects", "Math")}}
                                                      -

                                                      概述

                                                      +

                                                      概述

                                                      Math.tan() 方法返回一个数值的正切值。

                                                      -

                                                      语法

                                                      +

                                                      语法

                                                      Math.tan(x)
                                                      -

                                                      参数

                                                      +

                                                      参数

                                                      x
                                                      一个数值,表示一个角(单位:弧度)。
                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      tan 方法返回一个数值,表示一个角的正切值。

                                                      由于 tanMath 的静态方法,所以应该像这样使用 Math.tan(),而不是作为你创建的 Math 实例的方法。

                                                      -

                                                      示例

                                                      -

                                                      例子:使用 Math.tan

                                                      +

                                                      示例

                                                      +

                                                      例子:使用 Math.tan

                                                      下面的函数返回变量 x 的正切值:

                                                      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
                                                       
                                                       

                                                      Math.trunc() 方法会将数字的小数部分去掉,只保留整数部分。

                                                      -

                                                      语法

                                                      +

                                                      语法

                                                      Math.trunc(value)
                                                      -

                                                      参数

                                                      +

                                                      参数

                                                      value
                                                      @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/trunc

                                                      给定数字的整数部分

                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      不像 Math 的其他三个方法: {{jsxref("Math.floor()")}}、{{jsxref("Math.ceil()")}}、{{jsxref("Math.round()")}} ,Math.trunc() 的执行逻辑很简单,仅仅是删除掉数字的小数部分和小数点,不管参数是正数还是负数。

                                                      @@ -35,7 +35,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/trunc

                                                      因为 trunc()Math 对象的静态方法,你必须用 Math.trunc() 来使用,而不是调用你创建的 Math 对象的一个实例方法(Math 没有构造函数)

                                                      -

                                                      示例

                                                      +

                                                      示例

                                                      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
                                                       
                                                       
                                                      {{EmbedInteractiveExample("pages/js/globalprops-nan.html")}}
                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      NaN 是一个全局对象的属性。

                                                      @@ -59,7 +59,7 @@ Number.isNaN('hello world'); // false

                                                      {{Compat("javascript.builtins.NaN")}}

                                                      -

                                                      相关链接

                                                      +

                                                      相关链接

                                                      • {{jsxref("Number.NaN")}}
                                                      • 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

                                                        最近出了stage3{{jsxref("BigInt")}} 任意精度数字类型,已经进入stage3规范

                                                        -

                                                        语法

                                                        +

                                                        语法

                                                        new Number(value);
                                                         var a = new Number('123'); // a === 123 is false
                                                        @@ -23,14 +23,14 @@ var b = Number('123'); // b === 123 is true
                                                         a instanceof Number; // is true
                                                         b instanceof Number; // is false
                                                        -

                                                        参数

                                                        +

                                                        参数

                                                        value
                                                        被创建对象的数字值。
                                                        -

                                                        描述

                                                        +

                                                        描述

                                                        Number 对象主要用于:

                                                        @@ -39,7 +39,7 @@ var b = Number('123'); // b === 123 is true
                                                      • 在非构造器上下文中 (如:没有 {{jsxref("Operators/new", "new")}} 操作符),Number 能被用来执行类型转换。
                                                      -

                                                      属性

                                                      +

                                                      属性

                                                      {{jsxref("Number.EPSILON")}}
                                                      @@ -62,7 +62,7 @@ var b = Number('123'); // b === 123 is true
                                                      Number 对象上允许的额外属性。
                                                      -

                                                      方法

                                                      +

                                                      方法

                                                      {{jsxref("Number.isNaN()")}}
                                                      @@ -86,17 +86,17 @@ var b = Number('123'); // b === 123 is true
                                                      -

                                                      Number 实例

                                                      +

                                                      Number 实例

                                                      所有 Number 实例都继承自 {{jsxref("Number.prototype")}}。被修改的 Number 构造器的原型对象对全部 Number 实例都生效。

                                                      -

                                                      方法

                                                      +

                                                      方法

                                                      {{page('/zh-CN/docs/JavaScript/Reference/Global_Objects/Number/prototype', 'Methods')}}
                                                      -

                                                      示例

                                                      +

                                                      示例

                                                      -

                                                      使用 Number 对象给数字变量赋值

                                                      +

                                                      使用 Number 对象给数字变量赋值

                                                      下例使用 Number 对象的属性给几个数字变量赋值:

                                                      @@ -118,7 +118,7 @@ var smallestInt = Number.MIN_SAFE_INTEGER;

                                                      在解析序列化的JSON时,如果JSON解析器将它们强制转换为Number类型,那么超出此范围的整数值可能会被破坏。在工作中使用{{jsxref("String")}} 类型代替,是一个可行的解决方案。

                                                      -

                                                      使用 Number 转换 Date 对象

                                                      +

                                                      使用 Number 转换 Date 对象

                                                      下例使用 Number 作为函数来转换 Date 对象为数字值:

                                                      @@ -175,13 +175,13 @@ Number('-Infinity') //-Infinity
                                                      -

                                                      浏览器兼容性

                                                      +

                                                      浏览器兼容性

                                                      {{Compat("javascript.builtins.Number")}}

                                                      -

                                                      参阅

                                                      +

                                                      参阅

                                                      • {{jsxref("NaN")}}
                                                      • 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

                                                        {{EmbedInteractiveExample("pages/js/number-isfinite.html")}}

                                                        -

                                                        语法

                                                        +

                                                        语法

                                                        Number.isFinite(value)
                                                        -

                                                        参数

                                                        +

                                                        参数

                                                        value
                                                        @@ -77,11 +77,11 @@ Number.isFinite(null); // false, would've been true with -

                                                        浏览器兼容性

                                                        +

                                                        浏览器兼容性

                                                        {{Compat("javascript.builtins.Number.isFinite")}}
                                                        -

                                                        相关链接

                                                        +

                                                        相关链接

                                                        • The {{jsxref("Number")}} object it belongs to.
                                                        • 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

                                                          {{EmbedInteractiveExample("pages/js/number-isinteger.html")}}

                                                          -

                                                          语法

                                                          +

                                                          语法

                                                          Number.isInteger(value)
                                                          -

                                                          参数

                                                          +

                                                          参数

                                                          value
                                                          @@ -30,11 +30,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/isInteger

                                                          判断给定值是否是整数的 {{jsxref("Boolean")}} 值。

                                                          -

                                                          描述

                                                          +

                                                          描述

                                                          如果被检测的值是整数,则返回 true,否则返回 false。注意 {{jsxref("Global_Objects/NaN", "NaN")}} 和正负 {{jsxref("Global_Objects/Infinity", "Infinity")}} 不是整数。

                                                          -

                                                          示例

                                                          +

                                                          示例

                                                          Number.isInteger(0);         // true
                                                           Number.isInteger(1);         // true
                                                          @@ -50,7 +50,7 @@ Number.isInteger(true);      // false
                                                           Number.isInteger(false);     // false
                                                           Number.isInteger([1]);       // false
                                                          -

                                                          Polyfill

                                                          +

                                                          Polyfill

                                                          Number.isInteger = Number.isInteger || function(value) {
                                                               return typeof value === "number" &&
                                                          @@ -81,11 +81,11 @@ Number.isInteger([1]);       // false
                                                          -

                                                          浏览器兼容性

                                                          +

                                                          浏览器兼容性

                                                          {{Compat("javascript.builtins.Number.isInteger")}}

                                                          -

                                                          相关链接

                                                          +

                                                          相关链接

                                                          • {{jsxref("Global_Objects/Number", "Number")}}
                                                          • 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

                                                            安全整数范围为 -(253 - 1)到 253 - 1 之间的整数,包含 -(253 - 1)和 253 - 1

                                                            -

                                                            语法

                                                            +

                                                            语法

                                                            Number.isSafeInteger(testValue)
                                                            -

                                                            参数

                                                            +

                                                            参数

                                                            testValue
                                                            @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/isSafeInteger

                                                            一个{{jsxref("Boolean", "布尔值")}} 表示给定的值是否是一个安全整数(safe integer)。

                                                            -

                                                            示例

                                                            +

                                                            示例

                                                            Number.isSafeInteger(3);                    // true
                                                             Number.isSafeInteger(Math.pow(2, 53))       // false
                                                            @@ -73,7 +73,7 @@ Number.isSafeInteger(3.0);                  // true
                                                              
                                                             
                                                             
                                                            -

                                                            浏览器兼容性

                                                            +

                                                            浏览器兼容性

                                                            {{Compat("javascript.builtins.Number.isSafeInteger")}}

                                                            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 ---
                                                            {{JSRef("Global_Objects", "Number")}}
                                                            -

                                                            概述

                                                            +

                                                            概述

                                                            Number.MAX_VALUE 属性表示在 JavaScript 里所能表示的最大数值。

                                                            {{js_property_attributes(0,0,0)}}

                                                            -

                                                            描述

                                                            +

                                                            描述

                                                            MAX_VALUE 属性值接近于 1.79E+308。大于 MAX_VALUE 的值代表 "Infinity"。

                                                            因为 MAX_VALUENumber 对象的一个静态属性,所以你应该直接使用Number.MAX_VALUE ,而不是作为一个创建的 Number 实例的属性。

                                                            -

                                                            示例

                                                            +

                                                            示例

                                                            -

                                                            例子:使用 MAX_VALUE

                                                            +

                                                            例子:使用 MAX_VALUE

                                                            下面的代码求两个数值的乘积。如果结果小于等于 MAX_VALUE,则调用 func1 函数;否则,调用 func2 函数。

                                                            @@ -108,7 +108,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE -

                                                            相关链接

                                                            +

                                                            相关链接

                                                            • {{jsxref("Number.MIN_VALUE")}}
                                                            • 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 ---
                                                              {{JSRef("Global_Objects", "Number")}}
                                                              -

                                                              概述

                                                              +

                                                              概述

                                                              Number.MIN_VALUE 属性表示在 JavaScript 中所能表示的最小的正值。

                                                              {{js_property_attributes(0,0,0)}}

                                                              -

                                                              描述

                                                              +

                                                              描述

                                                              MIN_VALUE 属性是 JavaScript 里最接近 0 的正值,而不是最小的负值。

                                                              MIN_VALUE 的值约为 5e-324。小于 MIN_VALUE ("underflow values") 的值将会转换为 0。

                                                              因为 MIN_VALUE 是 Number 的一个静态属性,因此应该直接使用: Number.MIN_VALUE, 而不是作为一个创建的 Number 实例的属性。

                                                              -

                                                              示例

                                                              -

                                                              例子:使用 MIN_VALUE

                                                              +

                                                              示例

                                                              +

                                                              例子:使用 MIN_VALUE

                                                              下面的代码里两个数值相除。如果结果大于或等于 MIN_VALUE,则调用 func1 函数;否则,调用 func2 函数。

                                                              if (num1 / num2 >= Number.MIN_VALUE) {
                                                                   func1();
                                                              @@ -93,7 +93,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE
                                                                 
                                                                
                                                               
                                                              -

                                                              相关链接

                                                              +

                                                              相关链接

                                                              • {{jsxref("Number.MAX_VALUE")}}
                                                              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 ---
                                                              {{JSRef("Global_Objects", "Number")}}
                                                              -

                                                              概述

                                                              +

                                                              概述

                                                              Number.NaN 表示“非数字”(Not-A-Number)。和 {{jsxref("Global_Objects/NaN", "NaN")}} 相同。

                                                              @@ -97,7 +97,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/NaN -

                                                              相关链接

                                                              +

                                                              相关链接

                                                              • 全局对象 {{jsxref("Global_Objects/NaN", "NaN")}}
                                                              • 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 ---
                                                                {{JSRef("Global_Objects", "Number")}}
                                                                -

                                                                概述

                                                                +

                                                                概述

                                                                Number.NEGATIVE_INFINITY 属性表示负无穷大。

                                                                不用创建一个 {{jsxref("Global_Objects/Number", "Number")}} 实例,使用 Number.NEGATIVE_INFINITY 来访问该静态属性。

                                                                {{js_property_attributes(0,0,0)}}

                                                                -

                                                                描述

                                                                +

                                                                描述

                                                                Number.NEGATIVE_INFINITY 的值和全局对象的 {{jsxref("Global_Objects/Infinity", "Infinity")}} 属性的负值相同。

                                                                该值的行为同数学上的无穷大(infinity)有一点儿不同:

                                                                  @@ -23,7 +23,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/NEGATIVE_INFINITY
                                                                • 任何数除以 NEGATIVE_INFINITY 为 0。

                                                                为了成功返回一个有限值,你可能会使用 Number.NEGATIVE_INFINITY 属性来判断是否显示一个条件错误 。然而 {{jsxref("Global_Objects/isFinite", "isFinite")}} 方法更适合这种情况。

                                                                -

                                                                示例

                                                                +

                                                                示例

                                                                下例中,赋值给变量 smallNumber 一个明显小于 JavaScript 中的最小值的值。当 if 语句执行时,smallNumber 值为 "-Infinity",因此在继续执行代码前,smallNumber 被设为一个更容易管理的值。

                                                                var smallNumber = (-Number.MAX_VALUE) * 2
                                                                 
                                                                @@ -104,7 +104,7 @@ if (smallNumber == Number.NEGATIVE_INFINITY) {
                                                                   
                                                                  
                                                                 
                                                                -

                                                                相关链接

                                                                +

                                                                相关链接

                                                                • {{jsxref("Number.POSITIVE_INFINITY")}}
                                                                • {{jsxref("Global_Objects/Infinity", "Infinity")}}
                                                                • 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 ---
                                                                  {{JSRef("Global_Objects", "Number")}}
                                                                  -

                                                                  概述

                                                                  +

                                                                  概述

                                                                  Number.parseFloat() 方法可以把一个字符串解析成浮点数。该方法与全局的 {{jsxref("Global_Objects/parseFloat", "parseFloat()")}} 函数相同,并且处于 ECMAScript 6 规范中(用于全局变量的模块化)。

                                                                  -

                                                                  语法

                                                                  +

                                                                  语法

                                                                  Number.parseFloat(string)
                                                                  -

                                                                  参数

                                                                  +

                                                                  参数

                                                                  string
                                                                  @@ -49,7 +49,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseFloat -

                                                                  浏览器兼容性

                                                                  +

                                                                  浏览器兼容性

                                                                  {{CompatibilityTable}}
                                                                  @@ -101,7 +101,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseFloat -

                                                                  相关链接

                                                                  +

                                                                  相关链接

                                                                  • {{jsxref("Global_Objects/Number", "Number")}}
                                                                  • 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 ---
                                                                    {{JSRef}}
                                                                    -

                                                                    概述

                                                                    +

                                                                    概述

                                                                    Number.parseInt() 方法依据指定基数 [ 参数 radix 的值],把字符串 [ 参数 string 的值] 解析成整数。

                                                                    -

                                                                    语法

                                                                    +

                                                                    语法

                                                                    Number.parseInt(string[, radix])
                                                                     
                                                                    @@ -74,7 +74,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseInt

                                                                    {{Compat("javascript.builtins.Number.parseInt")}}

                                                                    -

                                                                    相关链接

                                                                    +

                                                                    相关链接

                                                                    • {{jsxref("Global_Objects/Number", "Number()")}}
                                                                    • 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) { -

                                                                      相关链接

                                                                      +

                                                                      相关链接

                                                                      • {{jsxref("Number.NEGATIVE_INFINITY")}}
                                                                      • 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 ---
                                                                        {{JSRef("Global_Objects", "Number")}}
                                                                        -

                                                                        概述

                                                                        +

                                                                        概述

                                                                        toExponential() 方法以指数表示法返回该数值字符串表示形式。

                                                                        -

                                                                        语法

                                                                        +

                                                                        语法

                                                                        numObj.toExponential(fractionDigits)
                                                                        -

                                                                        参数

                                                                        +

                                                                        参数

                                                                        fractionDigits
                                                                        可选。一个整数,用来指定小数点后有几位数字。默认情况下用尽可能多的位数来显示数字。
                                                                        -

                                                                        返回值

                                                                        +

                                                                        返回值

                                                                        一个用幂的形式 (科学记数法) 来表示{{jsxref("Number")}} 对象的字符串。小数点后以fractionDigits 提供的值来四舍五入。如果 fractionDigits 参数被忽略了,小数点后的将尽可能用最多的位数来表示该数值。

                                                                        @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toExponential

                                                                        如果一个数值的小数位数多余 fractionDigits 参数所提供的,则该数值将会在 fractionDigits 指定的小数位数处四舍五入。可以查看 {{jsxref("Number.toFixed", "toFixed()")}} 方法描述中关于四舍五入的讨论,同样应用于 toExponential() 方法。

                                                                        -

                                                                        异常

                                                                        +

                                                                        异常

                                                                        {{jsxref("Global_Objects/RangeError", "RangeError")}}
                                                                        @@ -40,7 +40,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toExponential
                                                                        如果该方法在一个非数值类型对象上调用。
                                                                        -

                                                                        示例

                                                                        +

                                                                        示例

                                                                        var numObj = 77.1234;
                                                                         
                                                                        @@ -133,7 +133,7 @@ alert("77 .toExponential() is " + 77 .toExponential()); //输出 7.7e+1
                                                                        -

                                                                        相关链接

                                                                        +

                                                                        相关链接

                                                                        • {{jsxref("Number.prototype.toFixed()")}}
                                                                        • 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
                                                                          {{EmbedInteractiveExample("pages/js/number-tofixed.html")}}
                                                                          -

                                                                          语法

                                                                          +

                                                                          语法

                                                                          numObj.toFixed(digits)
                                                                          -

                                                                          参数

                                                                          +

                                                                          参数

                                                                          digits
                                                                          小数点后数字的个数;介于 0 到 20 (包括)之间,实现环境可能支持更大范围。如果忽略该参数,则默认为 0。
                                                                          -

                                                                          返回值

                                                                          +

                                                                          返回值

                                                                          使用定点表示法表示给定数字的字符串。

                                                                          -

                                                                          抛出异常

                                                                          +

                                                                          抛出异常

                                                                          {{jsxref("RangeError")}}
                                                                          @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toFixed

                                                                          Warning: 浮点数不能精确地用二进制表示所有小数。这可能会导致意外的结果,例如 0.1 + 0.2 === 0.3 返回 false .

                                                                          -

                                                                          示例

                                                                          +

                                                                          示例

                                                                          使用 toFixed

                                                                          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 ---
                                                                          {{JSRef("Global_Objects", "Number")}}
                                                                          -

                                                                          概述

                                                                          +

                                                                          概述

                                                                          toPrecision() 方法以指定的精度返回该数值对象的字符串表示。

                                                                          -

                                                                          语法

                                                                          +

                                                                          语法

                                                                          numObj.toPrecision(precision)
                                                                          -

                                                                          参数

                                                                          +

                                                                          参数

                                                                          precision
                                                                          可选。一个用来指定有效数个数的整数。
                                                                          -

                                                                          返回值

                                                                          +

                                                                          返回值

                                                                          以定点表示法或指数表示法表示的一个数值对象的字符串表示,四舍五入到 precision 参数指定的显示数字位数。查看 {{jsxref("Number.prototype.toFixed()")}} 方法关于四舍五入的讨论,同样应用于 toPrecision 方法。

                                                                          @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toPrecision
                                                                          如果 precison 参数不在 1 和 100 (包括)之间,将会抛出一个 RangeError 。执行环境也可以支持更大或更小的范围。ECMA-262 只需要最多 21 位显示数字。
                                                                          -

                                                                          示例

                                                                          +

                                                                          示例

                                                                          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"
                                                                           
                                                                           
                                                                           
                                                                          -

                                                                          相关链接

                                                                          +

                                                                          相关链接

                                                                          • {{jsxref("Number.prototype.toFixed()")}}
                                                                          • 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 ---
                                                                            {{JSRef("Global_Objects", "Number")}} {{ Non-standard_header() }}
                                                                            -

                                                                            概述

                                                                            +

                                                                            概述

                                                                            toSource() 方法返回该对象源码的字符串表示。

                                                                            -

                                                                            语法

                                                                            +

                                                                            语法

                                                                            numObj.toSource();
                                                                             Number.toSource();
                                                                             
                                                                            -

                                                                            参数

                                                                            +

                                                                            参数

                                                                            -

                                                                            描述

                                                                            +

                                                                            描述

                                                                            toSource() 方法返回下列值:

                                                                              @@ -74,7 +74,7 @@ Number.toSource(); -

                                                                              相关链接

                                                                              +

                                                                              相关链接

                                                                              • {{jsxref("Object.prototype.toSource()")}}
                                                                              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

                                                                              toString() 方法返回指定 {{jsxref("Number")}} 对象的字符串表示形式。

                                                                              -

                                                                              语法

                                                                              +

                                                                              语法

                                                                              numObj.toString([radix])
                                                                               
                                                                              -

                                                                              参数

                                                                              +

                                                                              参数

                                                                              radix
                                                                              @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toString
                                                                              -

                                                                              描述

                                                                              +

                                                                              描述

                                                                              {{jsxref("Number")}} 对象覆盖了 {{jsxref("Object")}} 对象上的 toString() 方法,它不是继承的 {{jsxref("Object.prototype.toString()")}}。对于 {{jsxref( "Number")}} 对象,toString() 方法以指定的基数返回该对象的字符串表示。

                                                                              @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toString

                                                                              进行数字到字符串的转换时,建议用小括号将要转换的目标括起来,防止出错。

                                                                              -

                                                                              例子

                                                                              +

                                                                              例子

                                                                              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
                                                                               ---
                                                                               
                                                                              {{JSRef("Global_Objects", "Number")}}
                                                                              -

                                                                              概述

                                                                              +

                                                                              概述

                                                                              valueOf() 方法返回一个被 {{jsxref("Global_Objects/Number", "Number")}} 对象包装的原始值。

                                                                              -

                                                                              语法

                                                                              +

                                                                              语法

                                                                              numObj.valueOf()
                                                                              -

                                                                              返回值

                                                                              +

                                                                              返回值

                                                                              表示指定 {{jsxref("Number")}} 对象的原始值的数字

                                                                              -

                                                                              描述

                                                                              +

                                                                              描述

                                                                              该方法通常是由 JavaScript 引擎在内部隐式调用的,而不是由用户在代码中显式调用的。

                                                                              -

                                                                              示例

                                                                              +

                                                                              示例

                                                                              var numObj = new Number(10);
                                                                               console.log(typeof numObj); // object
                                                                              @@ -115,7 +115,7 @@ console.log(typeof num);    // number
                                                                               
                                                                               
                                                                               
                                                                              -

                                                                              相关链接

                                                                              +

                                                                              相关链接

                                                                              • {{jsxref("Number.prototype.toSource()")}}
                                                                              • 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__ ---
                                                                                {{JSRef("Global_Objects", "Object")}} {{non-standard_header}} {{deprecated_header}}
                                                                                -

                                                                                概述

                                                                                +

                                                                                概述

                                                                                __defineGetter__ 方法可以将一个函数绑定在当前对象的指定属性上,当那个属性的值被读取时,你所绑定的函数就会被调用。

                                                                                -

                                                                                语法

                                                                                +

                                                                                语法

                                                                                obj.__defineGetter__(prop, func)
                                                                                -

                                                                                参数

                                                                                +

                                                                                参数

                                                                                prop
                                                                                @@ -20,9 +20,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineGetter__
                                                                                一个函数,当 prop 属性的值被读取时自动被调用。
                                                                                -

                                                                                描述

                                                                                +

                                                                                描述

                                                                                __defineGetter__ 方法可以为一个已经存在的对象设置(新建或修改)访问器属性,而 {{jsxref("Operators/get", "对象字面量中的 get 语法", "", 1)}} 只能在新建一个对象时使用。

                                                                                -

                                                                                示例

                                                                                +

                                                                                示例

                                                                                // 请注意,该方法是非标准的:
                                                                                 
                                                                                 var o = {};
                                                                                @@ -45,9 +45,9 @@ Object.defineProperty(o, 'gimmeFive', {
                                                                                 });
                                                                                 console.log(o.gimmeFive); // 5
                                                                                 
                                                                                -

                                                                                规范

                                                                                +

                                                                                规范

                                                                                不属于任何规范。

                                                                                -

                                                                                浏览器兼容性

                                                                                +

                                                                                浏览器兼容性

                                                                                {{CompatibilityTable}}
                                                                                @@ -96,7 +96,7 @@ console.log(o.gimmeFive); // 5
                                                                                -

                                                                                相关链接

                                                                                +

                                                                                相关链接

                                                                                • {{jsxref("Object.prototype.__defineSetter__()")}}
                                                                                • {{jsxref("Operators/get", "get")}} operator
                                                                                • 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__ ---
                                                                                  {{JSRef("Global_Objects", "Object")}} {{non-standard_header}} {{deprecated_header}}
                                                                                  -

                                                                                  概述

                                                                                  +

                                                                                  概述

                                                                                  __defineSetter__ 方法可以将一个函数绑定在当前对象的指定属性上,当那个属性被赋值时,你所绑定的函数就会被调用。

                                                                                  -

                                                                                  语法

                                                                                  +

                                                                                  语法

                                                                                  obj.__defineSetter__(prop, fun)
                                                                                  -

                                                                                  参数

                                                                                  +

                                                                                  参数

                                                                                  prop
                                                                                  @@ -28,11 +28,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__
                                                                  -

                                                                  描述

                                                                  +

                                                                  描述

                                                                  __defineSetter__ 方法可以为一个已经存在的对象设置(新建或修改)访问器属性,而 {{jsxref("Operators/set", "对象字面量中的 set 语法", "", 1)}} 只能在新建一个对象时使用。

                                                                  -

                                                                  规范

                                                                  +

                                                                  规范

                                                                  不属于任何规范。

                                                                  -

                                                                  浏览器兼容性

                                                                  +

                                                                  浏览器兼容性

                                                                  {{CompatibilityTable}}
                                                                  @@ -81,7 +81,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__
                                                                  -

                                                                  相关链接

                                                                  +

                                                                  相关链接

                                                                  • {{jsxref("Object.prototype.__defineGetter__()")}}
                                                                  • {{jsxref("Operators/set", "set")}} operator
                                                                  • 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__ ---
                                                                    {{JSRef("Global_Objects", "Object")}} {{ Non-standard_header }} {{ Deprecated_header }}
                                                                    -

                                                                    概述

                                                                    +

                                                                    概述

                                                                    __lookupGetter__ 方法会返回当前对象上指定属性的属性读取访问器函数(getter)。

                                                                    -

                                                                    语法

                                                                    +

                                                                    语法

                                                                    obj.__lookupGetter__(sprop)
                                                                    -

                                                                    参数

                                                                    +

                                                                    参数

                                                                    sprop
                                                                    属性名
                                                                    -

                                                                    示例

                                                                    +

                                                                    示例

                                                                    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"}) 
                                                                    -

                                                                    附注

                                                                    +

                                                                    附注

                                                                    __lookupGetter__ 方法是非标准的,我们应该使用标准中定义的方法来完成同样的事情,那就是 {{jsxref("Object.getOwnPropertyDescriptor()")}} 方法:

                                                                    @@ -53,7 +53,7 @@ Object.getOwnPropertyDescriptor(prototype, "foo").get // function __proto__() {[native code]}
                                                                -

                                                                规范

                                                                +

                                                                规范

                                                                不属于任何规范。

                                                                @@ -109,7 +109,7 @@ Object.getOwnPropertyDescriptor(prototype, "foo").get -

                                                                相关链接

                                                                +

                                                                相关链接

                                                                • {{jsxref("Object.__lookupSetter__", "Object.prototype.__lookupSetter__()")}}
                                                                • 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 -

                                                                  语法

                                                                  +

                                                                  语法

                                                                  Object.assign(target, ...sources)
                                                                  -

                                                                  参数

                                                                  +

                                                                  参数

                                                                  target
                                                                  @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign
                                                                  源对象。
                                                                  -

                                                                  返回值

                                                                  +

                                                                  返回值

                                                                  目标对象。

                                                                  @@ -83,16 +83,16 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign }); }
                                                              -

                                                              示例

                                                              +

                                                              示例

                                                              -

                                                              复制一个对象

                                                              +

                                                              复制一个对象

                                                              const obj = { a: 1 };
                                                               const copy = Object.assign({}, obj);
                                                               console.log(copy); // { a: 1 }
                                                               
                                                              -

                                                              深拷贝问题

                                                              +

                                                              深拷贝问题

                                                              针对深拷贝,需要使用其他办法,因为 Object.assign()拷贝的是(可枚举)属性值。

                                                              @@ -137,7 +137,7 @@ function test() { test();
                                                            -

                                                            合并对象

                                                            +

                                                            合并对象

                                                            const o1 = { a: 1 };
                                                             const o2 = { b: 2 };
                                                            @@ -159,7 +159,7 @@ console.log(obj); // { a: 1, b: 2, c: 3 }

                                                            属性被后续参数中具有相同属性的其他对象覆盖。

                                                            -

                                                            拷贝 symbol 类型的属性

                                                            +

                                                            拷贝 symbol 类型的属性

                                                            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)]
                                                            -

                                                            继承属性和不可枚举属性是不能拷贝的

                                                            +

                                                            继承属性和不可枚举属性是不能拷贝的

                                                            const obj = Object.create({foo: 1}, { // foo 是个继承属性。
                                                                 bar: {
                                                            @@ -184,7 +184,7 @@ const copy = Object.assign({}, obj);
                                                             console.log(copy); // { baz: 3 }
                                                             
                                                            -

                                                            原始类型会被包装为对象

                                                            +

                                                            原始类型会被包装为对象

                                                            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" }
                                                            -

                                                            异常会打断后续拷贝任务

                                                            +

                                                            异常会打断后续拷贝任务

                                                            const target = Object.defineProperty({}, "foo", {
                                                                 value: 1,
                                                            @@ -214,7 +214,7 @@ console.log(target.foo3); // undefined,异常之后 assign 方法就退出了
                                                             console.log(target.baz);  // undefined,第三个源对象更是不会被拷贝到的。
                                                             
                                                            -

                                                            拷贝访问器

                                                            +

                                                            拷贝访问器

                                                            const obj = {
                                                               foo: 1,
                                                            @@ -251,7 +251,7 @@ console.log(copy);
                                                             // { foo:1, get bar() { return 2 } }
                                                             
                                                            -

                                                            Polyfill

                                                            +

                                                            Polyfill

                                                            此{{Glossary("Polyfill","polyfill")}}不支持 symbol 属性,因为ES5 中根本没有 symbol :

                                                            @@ -285,7 +285,7 @@ console.log(copy); }); }
                                                      -

                                                      规范

                                                      +

                                                      规范

                                                      @@ -307,11 +307,11 @@ console.log(copy);
                                                      -

                                                      浏览器兼容

                                                      +

                                                      浏览器兼容

                                                      {{Compat("javascript.builtins.Object.assign")}}

                                                      -

                                                      相关链接

                                                      +

                                                      相关链接

                                                      • {{jsxref("Object.defineProperties()")}}
                                                      • 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

                                                        返回创建实例对象的 {{jsxref("Object")}} 构造函数的引用。注意,此属性的值是对函数本身的引用,而不是一个包含函数名称的字符串。对原始类型来说,如1true"test",该值只可读。

                                                        -

                                                        描述

                                                        +

                                                        描述

                                                        所有对象都会从它的原型上继承一个 constructor 属性:

                                                        @@ -31,9 +31,9 @@ a.constructor === Array // true var n = new Number(3); n.constructor === Number; // true
                                                    -

                                                    示例

                                                    +

                                                    示例

                                                    -

                                                    打印一个对象的构造函数

                                                    +

                                                    打印一个对象的构造函数

                                                    以下示例创建一个原型,Tree,以及该类型的对象,即theTree。 然后打印theTree对象的constructor属性。

                                                    @@ -50,7 +50,7 @@ console.log( "theTree.constructor is " + theTree.constructor );
                                                this.name = name; }
                                              -

                                              改变对象的 constructor

                                              +

                                              改变对象的 constructor

                                              下面的例子展示了如何修改基本类型对象的 constructor 属性的值。只有 true, 1"test" 的不受影响,因为创建他们的是只读的原生构造函数(native constructors)。这个例子也说明了依赖一个对象的 constructor 属性并不安全。

                                              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
                                              {{EmbedInteractiveExample("pages/js/object-create.html", "taller")}}
                                              -

                                              语法

                                              +

                                              语法

                                              Object.create(proto,[propertiesObject])
                                              -

                                              参数

                                              +

                                              参数

                                              proto
                                              @@ -29,15 +29,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/create
                                              可选。需要传入一个对象,该对象的属性类型参照{{jsxref("Object.defineProperties()")}}的第二个参数。如果该参数被指定且不为 {{jsxref("undefined")}},该传入对象的自有可枚举属性(即其自身定义的属性,而不是其原型链上的枚举属性)将为新创建的对象添加指定的属性值和对应的属性描述符。
                                              -

                                              返回值

                                              +

                                              返回值

                                              一个新对象,带着指定的原型对象和属性。

                                              -

                                              例外

                                              +

                                              例外

                                              如果proto参数不是 {{jsxref("null")}} 或非原始包装对象,则抛出一个 {{jsxref("TypeError")}} 异常。

                                              -

                                              例子

                                              +

                                              例子

                                              用 Object.create实现类式继承

                                              @@ -213,7 +213,7 @@ o2 = Object.create({}, {

                                              {{Compat("javascript.builtins.Object.create")}}

                                              -

                                              相关链接

                                              +

                                              相关链接

                                              • {{jsxref("Object.defineProperty")}}
                                              • 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

                                                Object.defineProperties() 方法直接在一个对象上定义新的属性或修改现有属性,并返回该对象。

                                                -

                                                语法

                                                +

                                                语法

                                                Object.defineProperties(objprops)
                                                -

                                                参数

                                                +

                                                参数

                                                obj
                                                @@ -172,7 +172,7 @@ Object.defineProperties(obj, {

                                                {{Compat("javascript.builtins.Object.defineProperties")}}

                                                -

                                                相关链接

                                                +

                                                相关链接

                                                • {{jsxref("Object.defineProperty()")}}
                                                • 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 -

                                                  语法

                                                  +

                                                  语法

                                                  Object.freeze(obj)
                                                  -

                                                  参数

                                                  +

                                                  参数

                                                  obj
                                                  @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/freeze

                                                  被冻结的对象。

                                                  -

                                                  描述

                                                  +

                                                  描述

                                                  被冻结对象自身的所有属性都不可能以任何方式被修改。任何修改尝试都会失败,无论是静默地还是通过抛出{{jsxref("TypeError")}}异常(最常见但不仅限于{{jsxref("Strict_mode", "strict mode", "", 1)}})。

                                                  @@ -39,7 +39,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/freeze

                                                  这个方法返回传递的对象,而不是创建一个被冻结的副本。

                                                  -

                                                  例子

                                                  +

                                                  例子

                                                  冻结对象

                                                  @@ -193,7 +193,7 @@ TypeError: 1 is not an object // ES5 code

                                                  {{Compat("javascript.builtins.Object.freeze")}}

                                                  -

                                                  相关链接

                                                  +

                                                  相关链接

                                                  • {{jsxref("Object.isFrozen")}}
                                                  • 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

                                                    {{EmbedInteractiveExample("pages/js/object-getownpropertydescriptor.html")}}

                                                    -

                                                    语法

                                                    +

                                                    语法

                                                    Object.getOwnPropertyDescriptor(obj, prop)
                                                    -

                                                    参数

                                                    +

                                                    参数

                                                    obj
                                                    @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes

                                                    如果指定的属性存在于对象上,则返回其属性描述符对象(property descriptor),否则返回 {{jsxref("undefined")}}。

                                                    -

                                                    描述

                                                    +

                                                    描述

                                                    该方法允许对一个属性的描述进行检索。在 Javascript 中, 属性 由一个字符串类型的“名字”(name)和一个“属性描述符”(property descriptor)对象构成。更多关于属性描述符类型以及他们属性的信息可以查看:{{jsxref("Object.defineProperty")}}.

                                                    @@ -52,7 +52,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes
                                                    当且仅当指定对象的属性可以被枚举出时,为 true
                                                    -

                                                    示例

                                                    +

                                                    示例

                                                    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
                                                     
                                                     

                                                    Object.getOwnPropertyNames()方法返回一个由指定对象的所有自身属性的属性名(包括不可枚举属性但不包括Symbol值作为名称的属性)组成的数组。

                                                    -

                                                    语法

                                                    +

                                                    语法

                                                    Object.getOwnPropertyNames(obj)
                                                    @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNam

                                                    在给定对象上找到的自身属性对应的字符串数组。

                                                    -

                                                    描述

                                                    +

                                                    描述

                                                    Object.getOwnPropertyNames() 返回一个数组,该数组对元素是 obj自身拥有的枚举或不可枚举属性名称字符串。 数组中枚举属性的顺序与通过 {{jsxref("Statements/for...in", "for...in")}} 循环(或 {{jsxref("Object.keys")}})迭代该对象属性时一致。数组中不可枚举属性的顺序未定义。

                                                    @@ -109,7 +109,7 @@ console.log(nonenum_only);
                                                    注:Array.filter(filt_func)方法创建一个新数组, 其包含通过所提供函数实现的测试的所有元素。
                                                    -

                                                    提示

                                                    +

                                                    提示

                                                    在 ES5 中,如果参数不是一个原始对象类型,将抛出一个 {{jsxref("TypeError")}}  异常。在 ES2015 中,非对象参数被强制转换为对象 

                                                    @@ -155,7 +155,7 @@ Object.getOwnPropertyNames('foo');

                                                    Firefox 28 {{geckoRelease("28")}}之前,Object.getOwnPropertyNames 不会获取到 {{jsxref("Error")}} 对象的属性。该 bug 在后面的版本修复了 ({{bug("724768")}})。

                                                    -

                                                    相关链接

                                                    +

                                                    相关链接

                                                    • Enumerability and ownership of properties
                                                    • 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

                                                      Object.getOwnPropertySymbols() 方法返回一个给定对象自身的所有 Symbol 属性的数组。

                                                      -

                                                      语法

                                                      +

                                                      语法

                                                      Object.getOwnPropertySymbols(obj)
                                                      -

                                                      参数

                                                      +

                                                      参数

                                                      obj
                                                      @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySym
                                                      在给定对象自身上找到的所有 Symbol 属性的数组。
                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      与{{jsxref("Object.getOwnPropertyNames()")}}类似,您可以将给定对象的所有符号属性作为 Symbol 数组获取。 请注意,{{jsxref("Object.getOwnPropertyNames()")}}本身不包含对象的 Symbol 属性,只包含字符串属性。

                                                      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

                                                      {{EmbedInteractiveExample("pages/js/object-getprototypeof.html")}}

                                                      -

                                                      示例

                                                      +

                                                      示例

                                                      var proto = {};
                                                       var obj = Object.create(proto);
                                                      @@ -65,7 +65,7 @@ Object.prototype === Object.getPrototypeOf( obj );              // true
                                                       
                                                       Object.prototype === Object.getPrototypeOf( {} );               // true
                                                      -

                                                      Notes

                                                      +

                                                      Notes

                                                      在 ES5 中,如果参数不是一个对象类型,将抛出一个{{jsxref("TypeError")}}异常。在 ES2015 中,参数会被强制转换为一个 {{jsxref("Object")}}

                                                      @@ -109,7 +109,7 @@ Object.getPrototypeOf('foo');

                                                      即使旧版本Opera不支持Object.getPrototypeOf(),Opera 10.50之后还支持非标准的 {{jsxref("Object.proto", "__proto__")}}属性。

                                                      -

                                                      相关链接

                                                      +

                                                      相关链接

                                                      • {{jsxref("Object.prototype.isPrototypeOf")}}
                                                      • 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 -

                                                        示例

                                                        +

                                                        示例

                                                        -

                                                        给定 undefinednull 类型使用 Object

                                                        +

                                                        给定 undefinednull 类型使用 Object

                                                        下面的例子将一个空的 Object 对象存到 o 中:

                                                        @@ -301,7 +301,7 @@ Object.prototype.valueOf = function() {

                                                        {{Compat("javascript.builtins.Object")}}

                                                        -

                                                        相关链接

                                                        +

                                                        相关链接

                                                        • 初始化对象
                                                        • 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 ---
                                                          {{JSRef("Global_Objects", "Object")}}
                                                          -

                                                          概述

                                                          +

                                                          概述

                                                          Object.isExtensible() 方法判断一个对象是否是可扩展的(是否可以在它上面添加新的属性)。

                                                          -

                                                          语法

                                                          +

                                                          语法

                                                          Object.isExtensible(obj)
                                                          -

                                                          参数

                                                          +

                                                          参数

                                                          obj
                                                          @@ -24,11 +24,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isExtensible

                                                              表示给定对象是否可扩展的一个Boolean 。

                                                          -

                                                          描述

                                                          +

                                                          描述

                                                          默认情况下,对象是可扩展的:即可以为他们添加新的属性。以及它们的 {{jsxref("Object.proto", "__proto__")}}{{deprecated_inline}} 属性可以被更改。{{jsxref("Object.preventExtensions")}},{{jsxref("Object.seal")}} 或 {{jsxref("Object.freeze")}} 方法都可以标记一个对象为不可扩展(non-extensible)。

                                                          -

                                                          例子

                                                          +

                                                          例子

                                                          // 新对象默认是可扩展的.
                                                           var empty = {};
                                                          @@ -133,7 +133,7 @@ Object.isExtensible(1);
                                                           
                                                           
                                                           
                                                          -

                                                          相关链接

                                                          +

                                                          相关链接

                                                          • {{jsxref("Object.preventExtensions")}}
                                                          • 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

                                                            Object.isFrozen()方法判断一个对象是否被{{jsxref("Object.freeze()", "冻结", "", 1)}}。

                                                            -

                                                            语法

                                                            +

                                                            语法

                                                            Object.isFrozen(obj)
                                                            -

                                                            参数

                                                            +

                                                            参数

                                                            obj
                                                            @@ -28,11 +28,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isFrozen
                                                            表示给定对象是否被冻结的{{jsxref("Boolean")}}。
                                                            -

                                                            描述

                                                            +

                                                            描述

                                                            一个对象是冻结的是指它不可{{jsxref("Object.isExtensible", "扩展")}},所有属性都是不可配置的,且所有数据属性(即没有getter或setter组件的访问器的属性)都是不可写的。

                                                            -

                                                            例子

                                                            +

                                                            例子

                                                            // 一个对象默认是可扩展的,所以它也是非冻结的.
                                                             Object.isFrozen({}); // === false
                                                            @@ -140,7 +140,7 @@ Object.isFrozen(1);
                                                             
                                                             

                                                            {{Compat("javascript.builtins.Object.isFrozen")}}

                                                            -

                                                            相关链接

                                                            +

                                                            相关链接

                                                            • {{jsxref("Object.freeze()")}}
                                                            • 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

                                                              如果这个对象是密封的,则返回 true,否则返回 false。密封对象是指那些不可 {{jsxref("Object.isExtensible", "扩展")}} 的,且所有自身属性都不可配置且因此不可删除(但不一定是不可写)的对象。

                                                              -

                                                              例子

                                                              +

                                                              例子

                                                              // 新建的对象默认不是密封的.
                                                               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
                                                               
                                                               

                                                              Object.keys() 方法会返回一个由一个给定对象的自身可枚举属性组成的数组,数组中属性名的排列顺序和正常循环遍历该对象时返回的顺序一致 。

                                                              -

                                                              语法

                                                              +

                                                              语法

                                                              Object.keys(obj)
                                                              -

                                                              参数

                                                              +

                                                              参数

                                                              obj
                                                              @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/keys

                                                              一个表示给定对象的所有可枚举属性的字符串数组。

                                                              -

                                                              描述

                                                              +

                                                              描述

                                                              Object.keys 返回一个所有元素为字符串的数组,其元素来自于从给定的object上面可直接枚举的属性。这些属性的顺序与手动遍历该对象属性时的一致。

                                                              @@ -146,7 +146,7 @@ Object.keys("foo");

                                                              {{Compat("javascript.builtins.Object.keys")}}

                                                              -

                                                              相关链接

                                                              +

                                                              相关链接

                                                              • Enumerability and ownership of properties
                                                              • 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

                                                                {{EmbedInteractiveExample("pages/js/object-preventextensions.html")}}

                                                                -

                                                                语法

                                                                +

                                                                语法

                                                                Object.preventExtensions(obj)
                                                                -

                                                                参数

                                                                +

                                                                参数

                                                                obj
                                                                @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/preventExtensions
                                                                已经不可扩展的对象。
                                                                -

                                                                描述

                                                                +

                                                                描述

                                                                如果一个对象可以添加新的属性,则这个对象是可扩展的。Object.preventExtensions()将对象标记为不再可扩展,这样它将永远不会具有它被标记为不可扩展时持有的属性之外的属性。注意,一般来说,不可扩展对象的属性可能仍然可被删除。尝试将新属性添加到不可扩展对象将静默失败或抛出{{jsxref("TypeError")}}(最常见的情况是{{jsxref("Functions_and_function_scope/Strict_mode", "strict mode", "", 1)}}中,但不排除其他情况)。

                                                                @@ -39,7 +39,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/preventExtensions

                                                                一旦将对象变为不可扩展的对象,就再也不能使其可扩展。

                                                                -

                                                                例子

                                                                +

                                                                例子

                                                                // Object.preventExtensions将原对象变的不可扩展,并且返回原对象.
                                                                 var obj = {};
                                                                @@ -117,7 +117,7 @@ Object.preventExtensions(1);
                                                                 
                                                                 

                                                                {{Compat("javascript.builtins.Object.preventExtensions")}}

                                                                -

                                                                相关链接

                                                                +

                                                                相关链接

                                                                • {{jsxref("Object.isExtensible()")}}
                                                                • 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 -

                                                                  语法

                                                                  +

                                                                  语法

                                                                  Object.seal(obj)
                                                                  -

                                                                  参数

                                                                  +

                                                                  参数

                                                                  obj
                                                                  @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/seal

                                                                  被密封的对象。

                                                                  -

                                                                  描述

                                                                  +

                                                                  描述

                                                                  通常,一个对象是{{jsxref("Object.isExtensible()", "可扩展的", "", 1)}}(可以添加新的属性)。密封一个对象会让这个对象变的不能添加新属性,且所有已有属性会变的不可配置。属性不可配置的效果就是属性变的不可删除,以及一个数据属性不能被重新定义成为访问器属性,或者反之。但属性的值仍然可以修改。尝试删除一个密封对象的属性或者将某个密封对象的属性从数据属性转换成访问器属性,结果会静默失败或抛出{{jsxref("TypeError")}}(在{{jsxref("Strict_mode", "严格模式", "", 1)}} 中最常见的,但不唯一)。

                                                                  @@ -41,7 +41,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/seal

                                                                  返回被密封对象的引用。

                                                                  -

                                                                  例子

                                                                  +

                                                                  例子

                                                                  var obj = {
                                                                     prop: function() {},
                                                                  @@ -132,7 +132,7 @@ Object.seal(1);
                                                                    
                                                                   
                                                                   
                                                                  -

                                                                  浏览器兼容

                                                                  +

                                                                  浏览器兼容

                                                                  @@ -140,7 +140,7 @@ Object.seal(1);

                                                                  {{Compat("javascript.builtins.Object.seal")}}

                                                                  -

                                                                  相关链接

                                                                  +

                                                                  相关链接

                                                                  • {{jsxref("Object.isSealed()")}}
                                                                  • 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

                                                                    警告: 由于现代 JavaScript 引擎优化属性访问所带来的特性的关系,更改对象的 [[Prototype]]各个浏览器和 JavaScript 引擎上都是一个很慢的操作。其在更改继承的性能上的影响是微妙而又广泛的,这不仅仅限于 obj.__proto__ = ... 语句上的时间花费,而且可能会延伸到任何代码,那些可以访问任何[[Prototype]]已被更改的对象的代码。如果你关心性能,你应该避免设置一个对象的 [[Prototype]]。相反,你应该使用 {{jsxref("Object.create()")}}来创建带有你想要的[[Prototype]]的新对象。

                                                                    -

                                                                    语法

                                                                    +

                                                                    语法

                                                                    Object.setPrototypeOf(obj, prototype)
                                                                    -

                                                                    参数

                                                                    +

                                                                    参数

                                                                    obj
                                                                    @@ -37,7 +37,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
                                                                    该对象的新原型(一个对象 或 {{jsxref("null")}}).
                                                                    -

                                                                    描述

                                                                    +

                                                                    描述

                                                                    如果对象的[[Prototype]]被修改成不可扩展(通过 {{jsxref("Object.isExtensible()")}}查看),就会抛出 {{jsxref("TypeError")}}异常。如果prototype参数不是一个对象或者{{jsxref("null")}}(例如,数字,字符串,boolean,或者 {{jsxref("undefined")}}),则什么都不做。否则,该方法将obj[[Prototype]]修改为新的值。

                                                                    @@ -47,7 +47,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
                                                                    var dict = Object.setPrototypeOf({}, null);
                                                                    -

                                                                    Polyfill

                                                                    +

                                                                    Polyfill

                                                                    我们必须借助非标准的  

                                                                    @@ -219,7 +219,7 @@ george(); // 'Hello guys!!'
                                                                  -

                                                                  相关链接

                                                                  +

                                                                  相关链接

                                                                  • {{jsxref("Reflect.setPrototypeOf()")}}
                                                                  • 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

                                                                    toLocaleString() 方法返回一个该对象的字符串表示。此方法被用于派生对象为了特定语言环境的目的(locale-specific purposes)而重载使用。

                                                                    -

                                                                    语法

                                                                    +

                                                                    语法

                                                                    obj.toLocaleString();
                                                                     
                                                                    @@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/toLocaleString

                                                                    表示对象的字符串。

                                                                    -

                                                                    描述

                                                                    +

                                                                    描述

                                                                    {{jsxref("Object")}} toLocaleString 返回调用 {{jsxref("Object.toString", "toString()")}} 的结果。

                                                                    @@ -71,7 +71,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/toLocaleString

                                                                    {{Compat("javascript.builtins.Object.toLocaleString")}}

                                                                    -

                                                                    相关链接

                                                                    +

                                                                    相关链接

                                                                    • {{jsxref("Object.prototype.toString()")}}
                                                                    • 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

                                                                      toSource()方法返回一个表示对象源代码的字符串。

                                                                      -

                                                                      语法

                                                                      +

                                                                      语法

                                                                      Object.toSource(); obj.toSource()
                                                                      -

                                                                      返回值

                                                                      +

                                                                      返回值

                                                                      一个表示对象的源代码的字符串。

                                                                      -

                                                                      描述

                                                                      +

                                                                      描述

                                                                      toSource()方法返回以下值:

                                                                      @@ -54,7 +54,7 @@ Person.prototype.toSource = function Person_toSource() { alert(new Person("Joe").toSource()); // ---> new Person("Joe")
                                                                -

                                                                内置的toSource方法

                                                                +

                                                                内置的toSource方法

                                                                每个JavaScript核心类型都有它自己的toSource()方法.这些对象是:

                                                                @@ -89,9 +89,9 @@ console.log('Cyclical: ' + (obj1.b.a == obj1));

                                                              如果使用循环结构, 并且需要 toSource(), 则对象必须提供对 toSource() 的重写,  无论是对构造函数的引用还是提供匿名函数。

                                                              -

                                                              示例

                                                              +

                                                              示例

                                                              -

                                                              使用toSource()

                                                              +

                                                              使用toSource()

                                                              下面的代码定义了一个Dog对象类型还创建了一个Dog类型的对象实例theDog

                                                              @@ -117,7 +117,7 @@ theDog = new Dog("Gabby", "Lab", "chocolate", "girl");

                                                            {{Compat("javascript.builtins.Object.toSource")}}

                                                            -

                                                            相关链接

                                                            +

                                                            相关链接

                                                            • {{jsxref("Object.prototype.toString()")}}
                                                            • 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

                                                              valueOf() 方法返回指定对象的原始值。

                                                              -

                                                              语法

                                                              +

                                                              语法

                                                              object.valueOf()
                                                              @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/valueOf

                                                              返回值为该对象的原始值。

                                                              -

                                                              描述

                                                              +

                                                              描述

                                                              JavaScript调用valueOf方法将对象转换为原始值。你很少需要自己调用valueOf方法;当遇到要预期的原始值的对象时,JavaScript会自动调用它。

                                                              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');

                                                          {{Compat("javascript.builtins.parseFloat")}}

                                                          -

                                                          相关链接

                                                          +

                                                          相关链接

                                                          • {{jsxref("Global_Objects/parseInt", "parseInt()")}}
                                                          • 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
                                                            parseInt('123', 5) // 将'123'看作5进制数,返回十进制数38 => 1*5^2 + 2*5^1 + 3*5^0 = 38
                                                            -

                                                            描述

                                                            +

                                                            描述

                                                            parseInt函数将其第一个参数转换为一个字符串,对该字符串进行解析,然后返回一个整数或 NaN

                                                            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

                                                            catch() 方法返回一个Promise,并且处理拒绝的情况。它的行为与调用{{jsxref("Promise.then", "Promise.prototype.then(undefined, onRejected)")}} 相同。 (事实上, calling obj.catch(onRejected) 内部calls obj.then(undefined, onRejected)).

                                                            -

                                                            语法

                                                            +

                                                            语法

                                                            p.catch(onRejected);
                                                             
                                                            @@ -34,7 +34,7 @@ p.catch(function(reason) {
                                                              
                                                             
                                                          -

                                                          描述

                                                          +

                                                          描述

                                                          catch 方法可以用于您的promise组合中的错误处理。

                                                          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
                                                          {{EmbedInteractiveExample("pages/js/promise-race.html")}}
                                                          -

                                                          语法

                                                          +

                                                          语法

                                                          Promise.race(iterable);
                                                          @@ -26,7 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/race

                                                          一个待定的 {{jsxref("Promise")}} 只要给定的迭代中的一个promise解决或拒绝,就采用第一个promise的值作为它的值,从而异步地解析或拒绝(一旦堆栈为空)。

                                                          -

                                                          描述

                                                          +

                                                          描述

                                                          race 函数返回一个 Promise,它将与第一个传递的 promise 相同的完成方式被完成。它可以是完成( resolves),也可以是失败(rejects),这要取决于第一个完成的方式是两个中的哪个。

                                                          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

                                                          {{EmbedInteractiveExample("pages/js/promise-reject.html")}}

                                                          -

                                                          语法

                                                          +

                                                          语法

                                                          Promise.reject(reason);
                                                          @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/reject
                                                          一个给定原因了的被拒绝的 {{jsxref("Promise")}}。
                                                  -

                                                  描述

                                                  +

                                                  描述

                                                  静态函数Promise.reject返回一个被拒绝的Promise对象。通过使用{{jsxref("Error")}}的实例获取错误原因reason对调试和选择性错误捕捉很有帮助。

                                                  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) //这会造成一个死循环
                                                  {{EmbedInteractiveExample("pages/js/promise-resolve.html")}}
                                                  -

                                                  语法

                                                  +

                                                  语法

                                                  Promise.resolve(value);
                                                   
                                                  @@ -48,7 +48,7 @@ Promise.resolve(thenable) //这会造成一个死循环

                                                  返回一个带着给定值解析过的Promise对象,如果参数本身就是一个Promise对象,则直接返回这个Promise对象。

                                                  -

                                                  描述

                                                  +

                                                  描述

                                                  静态方法 Promise.resolve返回一个解析过的Promise对象。

                                                  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 ---
                                                  {{JSRef("Global_Objects", "Error", "EvalError,InternalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError")}}
                                                  -

                                                  概述

                                                  +

                                                  概述

                                                  ReferenceError(引用错误) 对象代表当一个不存在的变量被引用时发生的错误。

                                                  -

                                                  语法

                                                  +

                                                  语法

                                                  new ReferenceError([message[, fileName[, lineNumber]]])
                                                  -

                                                  参数

                                                  +

                                                  参数

                                                  message
                                                  @@ -24,34 +24,34 @@ translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError
                                                  可选。引起异常的代码行号
                                                  -

                                                  描述

                                                  +

                                                  描述

                                                  当你尝试引用一个未被定义的变量时,将会抛出一个 ReferenceError

                                                  -

                                                  属性

                                                  +

                                                  属性

                                                  {{jsxref("ReferenceError.prototype")}}
                                                  Allows the addition of properties to an ReferenceError object.
                                                  -

                                                  方法

                                                  +

                                                  方法

                                                  全局的 ReferenceError 本身并不包含有方法,但是他可以从原型链上继承一些方法

                                                  -

                                                  ReferenceError 实例

                                                  +

                                                  ReferenceError 实例

                                                  -

                                                  属性

                                                  +

                                                  属性

                                                  {{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype', 'Properties')}}
                                                  -

                                                  方法

                                                  +

                                                  方法

                                                  {{page('/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError/prototype', 'Methods')}}
                                                  -

                                                  例子

                                                  +

                                                  例子

                                                  -

                                                  例: 捕获一个 ReferenceError

                                                  +

                                                  例: 捕获一个 ReferenceError

                                                  try {
                                                     var a = undefinedVariable;
                                                  @@ -66,7 +66,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError
                                                   }
                                                   
                                                  -

                                                  例: 创建一个 ReferenceError

                                                  +

                                                  例: 创建一个 ReferenceError

                                                  try {
                                                     throw new ReferenceError('Hello', 'someFile.js', 10);
                                                  @@ -160,7 +160,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError
                                                   
                                                   
                                                   
                                                  -

                                                  相关链接

                                                  +

                                                  相关链接

                                                  • {{jsxref("Error")}}
                                                  • 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 -

                                                    语法

                                                    +

                                                    语法

                                                    regexObj.exec(str)
                                                    -

                                                    参数

                                                    +

                                                    参数

                                                    str
                                                    要匹配正则表达式的字符串。
                                                    -

                                                    返回值

                                                    +

                                                    返回值

                                                    如果匹配成功,exec() 方法返回一个数组(包含额外的属性 index 和 input ,参见下方表格),并更新正则表达式对象的 {{jsxref("RegExp.lastIndex", "lastIndex")}} 属性。完全匹配成功的文本将作为返回数组的第一项,从第二项起,后续每项都对应正则表达式内捕获括号里匹配成功的文本。

                                                    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 ---
                                                    {{JSRef("Global_Objects", "RegExp")}}
                                                    -

                                                    概述

                                                    +

                                                    概述

                                                    global 属性表明正则表达式是否使用了 "g" 标志。global 是一个正则表达式实例的只读属性。

                                                    {{js_property_attributes(0,0,0)}}
                                                    -

                                                    描述

                                                    +

                                                    描述

                                                    global 的值是布尔对象,如果使用了 "g" 标志,则返回 true;否则返回 false。 "g" 标志意味着正则表达式应该测试字符串中所有可能的匹配。

                                                    你无法直接更改此属性。

                                                    -

                                                    示例

                                                    -

                                                    例子:使用 global

                                                    +

                                                    示例

                                                    +

                                                    例子:使用 global

                                                    var regex = new RegExp("foo", "g")
                                                     
                                                     console.log(regex.global) // true
                                                    @@ -97,7 +97,7 @@ console.log(regex.global) // true
                                                       
                                                      
                                                     
                                                    -

                                                    相关链接

                                                    +

                                                    相关链接

                                                    • {{jsxref("RegExp.prototype.ignoreCase")}}
                                                    • {{jsxref("RegExp.prototype.lastIndex")}}
                                                    • 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 ---
                                                      {{JSRef("Global_Objects", "RegExp")}}
                                                      -

                                                      概述

                                                      +

                                                      概述

                                                      ignoreCase 属性表明正则表达式是否使用了 "i" 标志。ignoreCase 是正则表达式实例的只读属性。

                                                      {{js_property_attributes(0,0,0)}}
                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      ignoreCase 的值是布尔对象,如果使用了"i" 标志,则返回 true;否则,返回 false。"i" 标志意味着在字符串进行匹配时,应该忽略大小写。

                                                      你无法直接更改此属性。

                                                      -

                                                      示例

                                                      -

                                                      例子:使用 ignoreCase

                                                      +

                                                      示例

                                                      +

                                                      例子:使用 ignoreCase

                                                      var regex = new RegExp("foo", "i")
                                                       
                                                       console.log(regex.ignoreCase) // true
                                                      @@ -97,7 +97,7 @@ console.log(regex.ignoreCase) // true
                                                         
                                                        
                                                       
                                                      -

                                                      相关链接

                                                      +

                                                      相关链接

                                                      • {{jsxref("RegExp.prototype.global")}}
                                                      • {{jsxref("RegExp.prototype.lastIndex")}}
                                                      • 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+/;
                                                      返回表示指定对象的字符串。重写{{jsxref("Object.prototype.toString()")}}方法。
                                                -

                                                示例

                                                +

                                                示例

                                                -

                                                使用正则改变数据结构

                                                +

                                                使用正则改变数据结构

                                                下例使用  {{jsxref("Global_Objects/String", "String")}} 的 {{jsxref("String.prototype.replace()", "replace()")}} 方法去匹配姓名 first last 输出新的格式 last, first

                                                @@ -152,7 +152,7 @@ s.match(/yes.*day/); s.match(/yes[^]*day/); // Returns 'yes\nmake my day'
                                        -

                                        使用带有 sticky 标志的正则表达式

                                        +

                                        使用带有 sticky 标志的正则表达式

                                        带有{{JSxRef("Global_Objects/RegExp/sticky", "sticky")}}标志的正则表达式将会从源字符串的{{jsxref("RegExp.prototype.lastIndex")}}位置开始匹配,也就是进行“粘性匹配”。

                                        @@ -179,7 +179,7 @@ while (r = re.exec("123 456")) console.log(r, "AND re.lastIndex", re.lastIndex);

                                        如果使用带有全局标志g的正则表达式re,就会捕获字符串中的所有6个数字,而非3个

                                        -

                                        使用正则表达式和 Unicode 字符

                                        +

                                        使用正则表达式和 Unicode 字符

                                        正如上面表格提到的,\w 或 \W 只会匹配基本的 ASCII 字符;如 a 到 zA 到 Z09_

                                        @@ -240,7 +240,7 @@ console.log(/[^.]+/.exec(url)[0].substr(7)); // logs "xxx" -

                                        浏览器兼容性

                                        +

                                        浏览器兼容性

                                        {{Compat("javascript.builtins.RegExp")}}

                                        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 ---
                                        {{JSRef("Global_Objects", "RegExp")}}
                                        -

                                        概述

                                        +

                                        概述

                                        lastIndex 是正则表达式的一个可读可写的整型属性,用来指定下一次匹配的起始索引。

                                        {{js_property_attributes(1,0,0)}}

                                        语法

                                        lastIndex = regExpObj.lastIndex;
                                        -

                                        描述

                                        +

                                        描述

                                        只有正则表达式使用了表示全局检索的 "g" 标志时,该属性才会起作用。此时应用下面的规则:

                                        • 如果 lastIndex 大于字符串的长度,则 regexp.test 和 regexp.exec 将会匹配失败,然后 lastIndex 被设置为 0。
                                        • @@ -111,7 +111,7 @@ console.log(re.lastIndex); -

                                          相关链接

                                          +

                                          相关链接

                                          • {{jsxref("RegExp.prototype.ignoreCase")}}
                                          • {{jsxref("RegExp.prototype.global")}}
                                          • 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 ---
                                            {{JSRef("Global_Objects", "RegExp")}}
                                            -

                                            概述

                                            +

                                            概述

                                            multiline 属性表明正则表达式是否使用了 "m" 标志。multiline 是正则表达式实例的一个只读属性。

                                            {{js_property_attributes(0,0,0)}}
                                            -

                                            描述

                                            +

                                            描述

                                            multiline 是一个布尔对象,如果使用了 "m" 标志,则返回 true;否则,返回 false。"m" 标志意味着一个多行输入字符串被看作多行。例如,使用 "m","^" 和 "$" 将会从只匹配正则字符串的开头或结尾,变为匹配字符串中任一行的开头或结尾。

                                            你无法直接更改此属性。

                                            -

                                            示例

                                            -

                                            例子:使用 multiline

                                            +

                                            示例

                                            +

                                            例子:使用 multiline

                                            var regex = new RegExp("foo", "m")
                                             
                                             console.log(regex.multiline) // true
                                            @@ -98,7 +98,7 @@ console.log(regex.multiline) // true
                                               
                                              
                                             
                                            -

                                            相关链接

                                            +

                                            相关链接

                                            • {{jsxref("RegExp.prototype.global")}}
                                            • {{jsxref("RegExp.prototype.lastIndex")}}
                                            • 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 ---
                                              {{JSRef("Global_Objects", "RegExp")}}
                                              -

                                              概述

                                              +

                                              概述

                                              source 属性返回一个值为当前正则表达式对象的模式文本的字符串,该字符串不会包含正则字面量两边的斜杠以及任何的标志字符。

                                              -

                                              示例

                                              +

                                              示例

                                              var regex = /fooBar/ig;
                                               
                                               console.log(regex.source); // "fooBar",不包含 /.../ 和 "ig"。
                                               
                                              -

                                              规范

                                              +

                                              规范

                                              @@ -50,7 +50,7 @@ console.log(regex.source); // "fooBar",不包含 /.../ 和 "ig"。
                                              -

                                              浏览器兼容性

                                              +

                                              浏览器兼容性

                                              {{CompatibilityTable}}
                                              @@ -102,7 +102,7 @@ console.log(regex.source); // "fooBar",不包含 /.../ 和 "ig"。 -

                                              相关链接

                                              +

                                              相关链接

                                              • {{jsxref("RegExp.prototype.flags")}}
                                              • 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
                                                {{EmbedInteractiveExample("pages/js/regexp-prototype-test.html", "taller")}}
                                                -

                                                语法

                                                +

                                                语法

                                                regexObj.test(str)
                                                -

                                                参数

                                                +

                                                参数

                                                str
                                                @@ -30,13 +30,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/test

                                                如果正则表达式与指定的字符串匹配 ,返回true;否则false

                                                -

                                                描述

                                                +

                                                描述

                                                当你想要知道一个正则表达式是否与指定的字符串匹配时,就可以使用 test()(类似于 {{jsxref("String.prototype.search()")}} 方法),差别在于test返回一个布尔值,而 search 返回索引(如果找到)或者-1(如果没找到);若想知道更多信息(然而执行比较慢),可使用{{jsxref("RegExp.prototype.exec()", "exec()")}} 方法(类似于 {{jsxref("String.prototype.match()")}} 方法)。 和 {{jsxref("RegExp.prototype.exec()", "exec()")}} (或者组合使用),一样,在相同的全局正则表达式实例上多次调用test将会越过之前的匹配。

                                                -

                                                示例

                                                +

                                                示例

                                                -

                                                使用 test()

                                                +

                                                使用 test()

                                                一个简单的例子,测试 "hello" 是否包含在字符串的最开始,返回布尔值。

                                                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 ---

                                                {{JSRef("Global_Objects", "RegExp")}}{{ Non-standard_header() }}

                                                -

                                                概述

                                                +

                                                概述

                                                返回一个字符串,代表当前对象的源代码

                                                -

                                                语法

                                                +

                                                语法

                                                regexObj.toSource()
                                                 
                                                -

                                                描述

                                                +

                                                描述

                                                toSource方法返回值如下:

                                                @@ -39,6 +39,6 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/toSource

                                                该方法通常由JavaScript内部隐含调用,而不会明确的出现在用户代码中.

                                                -

                                                相关链接

                                                +

                                                相关链接

                                                Object.prototype.toSource

                                                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 ---
                                                {{JSRef("Global_Objects", "RegExp")}}
                                                -

                                                概述

                                                +

                                                概述

                                                toString() 返回一个表示该正则表达式的字符串。

                                                -

                                                语法

                                                +

                                                语法

                                                regexObj.toString()
                                                -

                                                参数

                                                +

                                                参数

                                                -

                                                描述

                                                +

                                                描述

                                                {{jsxref("Global_Objects/RegExp", "RegExp")}} 对象覆盖了 {{jsxref("Global_Objects/Object", "Object")}} 对象的 toString() 方法,并没有继承 {{jsxref("Object.prototype.toString()")}}。对于 RegExp 对象,toString 方法返回一个该正则表达式的字符串形式。

                                                -

                                                示例

                                                -

                                                例子:使用 toString

                                                +

                                                示例

                                                +

                                                例子:使用 toString

                                                下例输出 RegExp 对象的字符串值:

                                                myExp = new RegExp("a+b+c");
                                                 alert(myExp.toString());       // 显示 "/a+b+c/"
                                                @@ -100,7 +100,7 @@ alert(foo.toString());         // 显示 "/bar/g"
                                                   
                                                  
                                                 
                                                -

                                                相关链接

                                                +

                                                相关链接

                                                • {{jsxref("Object.prototype.toString()")}}
                                                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 -

                                                语法

                                                +

                                                语法

                                                mySet.add(value);
                                                @@ -35,7 +35,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/add

                                                注意:不能添加重复的值

                                                -

                                                示例

                                                +

                                                示例

                                                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
                                                 
                                                 

                                                clear() 方法用来清空一个 Set 对象中的所有元素。

                                                -

                                                语法

                                                +

                                                语法

                                                mySet.clear();
                                                 
                                                @@ -23,7 +23,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/clear

                                                {{jsxref("undefined")}}.

                                                -

                                                示例

                                                +

                                                示例

                                                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
                                                 
                                                 

                                                delete() 方法可以从一个 Set 对象中删除指定的元素。

                                                -

                                                语法

                                                +

                                                语法

                                                mySet.delete(value);
                                                @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/delete

                                                成功删除返回 true,否则返回 false。

                                                -

                                                示例

                                                +

                                                示例

                                                var mySet = new Set();
                                                 mySet.add("foo");
                                                @@ -112,7 +112,7 @@ mySet.has("foo");    // 返回 false,"foo" 已经成功删除
                                                 
                                                 
                                                 
                                                -

                                                相关链接

                                                +

                                                相关链接

                                                • {{jsxref("Set")}}
                                                • 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 ---
                                                  {{JSRef("Global_Objects", "Set")}}
                                                  -

                                                  概述

                                                  +

                                                  概述

                                                  has() 方法返回一个布尔值来指示对应的值value是否存在Set对象中。

                                                  -

                                                  语法

                                                  +

                                                  语法

                                                  mySet.has(value);
                                                  @@ -31,9 +31,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/has
                                                  如果指定的值(value)存在于Set对象当中,返回true;否则返回 false
                                                -

                                                示例

                                                +

                                                示例

                                                -

                                                使用 has 方法

                                                +

                                                使用 has 方法

                                                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
                                                  
                                                构造函数用来创建派生对象.
                                        -

                                        实例属性

                                        +

                                        实例属性

                                        {{jsxref("Set.prototype.size")}}
                                        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");

                                        从{{gecko("17")}}开始  " (引号) 被 HTML引用字符 &quot所替代;在字符串中申请命名参数.

                                        -

                                        相关链接

                                        +

                                        相关链接

                                        • {{jsxref("String.prototype.link()")}}
                                        • 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 ---

                                          {{JSRef}}

                                          -

                                          概述

                                          +

                                          概述

                                          charAt() 方法从一个字符串中返回指定的字符。

                                          -

                                          语法

                                          +

                                          语法

                                          str.charAt(index)
                                          -

                                          参数

                                          +

                                          参数

                                          index
                                          @@ -24,13 +24,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/charAt
                                           
                                          -

                                          描述

                                          +

                                          描述

                                          字符串中的字符从左向右索引,第一个字符的索引值为 0,最后一个字符(假设该字符位于字符串 stringName 中)的索引值为 stringName.length - 1。 如果指定的 index 值超出了该范围,则返回一个空字符串。

                                          -

                                          示例

                                          +

                                          示例

                                          -

                                          例子:输出字符串中不同位置的字符

                                          +

                                          例子:输出字符串中不同位置的字符

                                          下例输出字符串 "Brave new world" 不同位置处的字符:

                                          @@ -269,7 +269,7 @@ function getWholeCharAndI (str, i) { -

                                          相关链接

                                          +

                                          相关链接

                                          • {{jsxref("String.prototype.indexOf()")}}, {{jsxref("String.prototype.lastIndexOf()")}}
                                          • 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

                                            向后兼容:在历史版本中(如 JavaScript 1.2),charCodeAt 返回一个数字,表示给定 index 处字符的 ISO-Latin-1 编码值。ISO-Latin-1 编码集范围从 0255。开头的 0127 直接匹配 ASCII 字符集。

                                            -

                                            示例

                                            +

                                            示例

                                            -

                                            使用 charCodeAt()

                                            +

                                            使用 charCodeAt()

                                            下例介绍了不同索引情况下返回的 Unicode 值:

                                            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

                                            concat() 方法将一个或多个字符串与原字符串连接合并,形成一个新的字符串并返回。

                                            -

                                            语法

                                            +

                                            语法

                                            str.concat(str2, [, ...strN])
                                            -

                                            参数

                                            +

                                            参数

                                            str2 [, ...strN]
                                            @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/concat

                                            一个新的字符串,包含参数所提供的连接字符串。

                                            -

                                            描述

                                            +

                                            描述

                                            concat 方法将一个或多个字符串与原字符串连接合并,形成一个新的字符串并返回。 concat 方法并不影响原字符串。

                                            @@ -37,9 +37,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/concat

                                            强烈建议使用赋值操作符+, +=)代替 concat 方法。

                                            -

                                            示例

                                            +

                                            示例

                                            -

                                            使用 concat

                                            +

                                            使用 concat

                                            下面的例子演示如何将多个字符串与原字符串合并为一个新字符串

                                            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 -

                                            语法

                                            +

                                            语法

                                            String.fromCharCode(num1[, ...[, numN]])
                                            -

                                            参数

                                            +

                                            参数

                                            num1, ..., numN
                                            @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/fromCharCode

                                            一个长度为 N 的字符串,由 N 个指定的 UTF-16 代码单元组成。

                                            -

                                            描述

                                            +

                                            描述

                                            该方法返回一个字符串,而不是一个  {{jsxref("String")}} 对象。

                                            @@ -81,7 +81,7 @@ String.fromCharCode(0xD834, 0xDF06, 0x61, 0xD834, 0xDF07); // "\uD834\uDF06a\uD8

                                            {{Compat("javascript.builtins.String.fromCharCode")}}

                                            -

                                            相关链接

                                            +

                                            相关链接

                                            • {{jsxref("String.prototype.charCodeAt()")}}
                                            • 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

                                              includes() 方法用于判断一个字符串是否包含在另一个字符串中,根据情况返回 true 或 false。

                                              -

                                              语法

                                              +

                                              语法

                                              str.includes(searchString[, position])
                                              @@ -60,7 +60,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/includes }; }
                                              -

                                              示例

                                              +

                                              示例

                                              使用 includes()

                                              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

                                              String 全局对象是一个用于字符串或一个字符序列的构造函数。

                                              -

                                              语法

                                              +

                                              语法

                                              字符串字面量采取以下形式:

                                              @@ -35,20 +35,20 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String
                                              String(thing)
                                               new String(thing)
                                              -

                                              参数

                                              +

                                              参数

                                              thing
                                              任何可以被转换成字符串的值。
                                              -

                                              模板字面量

                                              +

                                              模板字面量

                                              从 ECMAScript 2015 开始,字符串字面量也可以称为模板字面量

                                              `hello world` `hello! world!` `hello ${who}` escape `<a>${who}</a>`
                                              -

                                              转义字符

                                              +

                                              转义字符

                                              @@ -141,11 +141,11 @@ otherwise my code is unreadable.";
                                              -

                                              描述

                                              +

                                              描述

                                              字符串对于保存可以以文本形式表示的数据非常有用。 一些常用的字符串操作有:查询字符串长度,使用 + 和 += 运算符来构建和连接字符串,使用 indexOf 方法检查某一子字符串在父字符串中的位置,又或是使用 substring 方法提取从父字符串中提取子字符串。

                                              -

                                              从字符串中获取单个字符

                                              +

                                              从字符串中获取单个字符

                                              获取字符串的某个字符有两种方法。 第一种是使用 {{jsxref("String.charAt", "charAt")}} 方法:

                                              @@ -159,7 +159,7 @@ otherwise my code is unreadable.";

                                              使用括号访问字符串不可以对其进行删除或添加,因为字符串对应未知的属性并不是可读或配置的。 (更多的信息请参阅 {{jsxref("Object.defineProperty")}}。 )

                                              -

                                              字符串比较

                                              +

                                              字符串比较

                                              熟练使用 C 语言的开发者经常使用 strcmp 函数来比较字符串,但在 JavaScript 中,你只需要使用比较操作符(>/</>=/<=)

                                              @@ -212,7 +212,7 @@ console.log(eval(s2)); // returns the string "2 + 2"
                                              可以为 String 对象增加新的属性。
                                            -

                                            方法

                                            +

                                            方法

                                            {{jsxref("String.fromCharCode()")}}  
                                            @@ -247,7 +247,7 @@ console.log(String.replace(num, /5/, '2'));

                                            {{jsxref("Global_Objects/Array", "Generics", "#Array_generic_methods", 1)}} 在 Javascript 1.6 中同样支持{{jsxref("Global_Objects/Array", "Array")}}。

                                            -

                                            String 实例

                                            +

                                            String 实例

                                            属性

                                            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

                                            示例

                                            -

                                            使用indexOf() 和 lastIndexOf()

                                            +

                                            使用indexOf() 和 lastIndexOf()

                                            下例使用 indexOf()lastIndexOf() 方法定位字符串中 "Brave new world" 的值。

                                            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

                                            该方法将从尾到头地检索字符串 str,看它是否含有子串 searchValue。开始检索的位置在字符串的 fromIndex 处或字符串的结尾(没有指定 fromIndex 时)。如果找到一个 searchValue,则返回 searchValue 的第一个字符在 str 中的位置。str中的字符位置是从 0 开始的。

                                            -

                                            语法

                                            +

                                            语法

                                            str.lastIndexOf(searchValue[, fromIndex])
                                            -

                                            参数

                                            +

                                            参数

                                            searchValue
                                            @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf

                                            返回指定值最后一次出现的索引(该索引仍是以从左至右0开始记数的),如果没找到则返回-1。

                                            -

                                            描述

                                            +

                                            描述

                                            字符串中的字符被从左向右索引。首字符的索引(index)是 0,最后一个字符的索引是 stringName.length - 1

                                            @@ -47,15 +47,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf

                                            (例如'abadefgabm'.lastIndexOf('ab', 7) 返回7,虽然查找的'ab'中的b已经在 index=8的位置了从index=7的a处向左查找仍是能找到自身a加上其后连成ab,因为fromIndex指的是待匹配字符串的开头那一个)

                                            -

                                            区分大小写

                                            +

                                            区分大小写

                                            lastIndexOf 方法区分大小写。例如,下面的表达式返回 -1:

                                            "Blue Whale, Killer Whale".lastIndexOf("blue"); // returns -1
                                            -

                                            示例

                                            +

                                            示例

                                            -

                                            例子:使用 indexOflastIndexOf

                                            +

                                            例子:使用 indexOflastIndexOf

                                            下例使用 indexOf 和 lastIndexOf 方法来定位字符串 "Brave new world" 中的值。

                                            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 ---

                                            {{JSRef("Global_Objects", "String")}}

                                            -

                                            概述

                                            +

                                            概述

                                            length 属性表示一个字符串的长度。

                                            -

                                            描述

                                            +

                                            描述

                                            该属性返回字符串中字符编码单元的数量。JavaScript 使用 {{ interwiki("wikipedia", "UTF-16") }} 编码,该编码使用一个 16 比特的编码单元来表示大部分常见的字符,使用两个代码单元表示不常用的字符。因此 length 返回值可能与字符串中实际的字符数量不相同。

                                            @@ -22,7 +22,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/length

                                            静态属性 String.length 返回 1。

                                            -

                                            示例

                                            +

                                            示例

                                            var x = "Mozilla";
                                             var empty = "";
                                            @@ -112,7 +112,7 @@ console.log("The empty string is has a length of " + empty.length);
                                             
                                             
                                             
                                            -

                                            相关链接

                                            +

                                            相关链接

                                            • JavaScript String.length and Internationalizing Web Applications
                                            • 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

                                              使用 link 方法创建的链接将会成为 document.links 数组中的元素。查看 {{ Domxref("document.links") }}。

                                              -

                                              示例

                                              +

                                              示例

                                              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
                                              {{EmbedInteractiveExample("pages/js/string-match.html", "shorter")}}
                                              -

                                              语法

                                              +

                                              语法

                                              str.match(regexp)
                                              -

                                              参数

                                              +

                                              参数

                                              regexp
                                              @@ -42,11 +42,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match
                                              一个{{jsxref("Array")}},其内容取决于global(g)标志的存在与否,如果未找到匹配则为{{jsxref("null")}}。
                                              -

                                              描述

                                              +

                                              描述

                                              如果正则表达式不包含 标志,str.match() 将返回与 {{jsxref("RegExp.prototype.exec()", "RegExp.exec()")}}. 相同的结果。

                                              -

                                              参看:RegExp 方法

                                              +

                                              参看:RegExp 方法

                                              • 如果你需要知道一个字符串是否与一个正则表达式匹配 {{jsxref("RegExp")}} ,可使用 {{jsxref("RegExp.prototype.test()", "RegExp.test()")}} 。
                                              • @@ -54,9 +54,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match
                                              • 如果你想要获得捕获组,并且设置了全局标志,你需要用 {{jsxref("RegExp.prototype.exec()", "RegExp.exec()")}}  或者 {{jsxref("String.prototype.matchAll()", " String.prototype.matchAll()")}}
                                              -

                                              示例

                                              +

                                              示例

                                              -

                                              例子:使用 match

                                              +

                                              例子:使用 match

                                              在下例中,使用 match 查找 "Chapter" 紧跟着 1 个或多个数值字符,再紧跟着一个小数点和数值字符 0 次或多次。正则表达式包含 i 标志,因此大小写会被忽略。

                                              @@ -78,7 +78,7 @@ console.log(found); // 'index' 属性(22) 是整个匹配从零开始的索引。 // 'input' 属性是被解析的原始字符串。
                                            -

                                            例子:match 使用全局(global)和忽略大小写(ignore case)标志

                                            +

                                            例子:match 使用全局(global)和忽略大小写(ignore case)标志

                                            下例展示了 match 使用 global 和 ignore case 标志。A-E、a-e 的所有字母将会作为一个数组的元素返回。

                                            @@ -204,7 +204,7 @@ str3.match(null); // 返回["null"]
                                          • 从 Gecko 49 {{geckoRelease(49)}} 开始 , 不再支持非标准的标志参数 ({{bug(1108382)}}).
                                          -

                                          相关链接

                                          +

                                          相关链接

                                          • {{jsxref("RegExp")}}
                                          • 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

                                            repeat() 构造并返回一个新字符串,该字符串包含被连接在一起的指定数量的字符串的副本。

                                            -

                                            语法

                                            +

                                            语法

                                            str.repeat(count)
                                            -

                                            参数

                                            +

                                            参数

                                            count
                                            @@ -86,7 +86,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat } -

                                            示例

                                            +

                                            示例

                                            "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
                                              
                                             
                                             
                                            -

                                            浏览器兼容性

                                            +

                                            浏览器兼容性

                                            {{Compat("javascript.builtins.String.repeat")}}

                                            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 - #$*%
                                            -

                                            示例

                                            +

                                            示例

                                            replace() 中使用正则表达式

                                            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

                                            例 2:str.slice(2, -1) 提取第三个字符到倒数第一个字符。

                                            -

                                            例子

                                            +

                                            例子

                                            使用 slice() 创建一个新的字符串

                                            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 -

                                            语法

                                            +

                                            语法

                                            str.split([separator[, limit]])
                                             
                                            @@ -40,7 +40,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/split

                                            返回源字符串以分隔符出现位置分隔而成的一个 {{jsxref("Array")}} 

                                            -

                                            描述

                                            +

                                            描述

                                            找到分隔符后,将其从字符串中删除,并将子字符串的数组返回。如果没有找到或者省略了分隔符,则该数组包含一个由整个字符串组成的元素。如果分隔符为空字符串,则将str转换为字符数组。如果分隔符出现在字符串的开始或结尾,或两者都分开,分别以空字符串开头,结尾或两者开始和结束。因此,如果字符串仅由一个分隔符实例组成,则该数组由两个空字符串组成。

                                            @@ -48,9 +48,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/split

                                            {{Note("当字符串为空时,split()返回一个包含一个空字符串的数组,而不是一个空数组,如果字符串和分隔符都是空字符串,则返回一个空数组。")}}

                                            -

                                            示例

                                            +

                                            示例

                                            -

                                            使用 split()

                                            +

                                            使用 split()

                                            下例定义了一个函数:根据指定的分隔符将一个字符串分割成一个字符串数组。分隔字符串后,该函数依次输出原始字符串信息,被使用的分隔符,返回数组元素的个数,以及返回数组中所有的元素。

                                            @@ -91,7 +91,7 @@ The separator is: "," The array has 12 elements: Jan / Feb / Mar / Apr / May / Jun / Jul / Aug / Sep / Oct / Nov / Dec / -

                                            移出字符串中的空格

                                            +

                                            移出字符串中的空格

                                            下例中,split() 方法会查找“0 或多个空白符接着的分号,再接着 0 或多个空白符”模式的字符串,找到后,就将空白符从字符串中移除,nameListsplit 的返回数组。

                                            @@ -111,7 +111,7 @@ console.log(nameList); [ "Harry Trump", "Fred Barney", "Helen Rigby", "Bill Abel", "Chris Hand", "" ] -

                                            限制返回值中分割元素数量

                                            +

                                            限制返回值中分割元素数量

                                            下例中,split 查找字符串中的 0 或多个空格,并返回找到的前 3 个分割元素(splits)。

                                            @@ -125,7 +125,7 @@ console.log(splits);
                                            ["Hello", "World.", "How"]
                                            -

                                            靠正则来分割使结果中包含分隔块

                                            +

                                            靠正则来分割使结果中包含分隔块

                                            如果 separator 包含捕获括号(capturing parentheses),则其匹配结果将会包含在返回的数组中。

                                            @@ -203,7 +203,7 @@ const strReverse = str.split(/(?:)/u).reverse().join('');

                                            {{Compat("javascript.builtins.String.split")}}

                                            -

                                            相关链接

                                            +

                                            相关链接

                                            • {{jsxref("String.prototype.charAt()")}}
                                            • 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

                                              substr() 方法返回一个字符串中从指定位置开始到指定字符数的字符。

                                              -

                                              语法

                                              +

                                              语法

                                              str.substr(start[, length])
                                              -

                                              参数

                                              +

                                              参数

                                              start
                                              @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substr
                                              可选。提取的字符数。
                                              -

                                              描述

                                              +

                                              描述

                                              start 是一个字符的索引。首字符的索引为 0,最后一个字符的索引为 字符串的长度减去1。substrstart 位置开始提取字符,提取 length 个字符(或直到字符串的末尾)。

                                              @@ -39,7 +39,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substr

                                              示例

                                              -

                                              例子:使用 substr

                                              +

                                              例子:使用 substr

                                              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):
                                               
                                              -

                                              兼容旧环境(Polyfill)

                                              +

                                              兼容旧环境(Polyfill)

                                              Microsoft's JScript 不支持负的 start 索引。如果你想充分利用该方法的功能,则需要使用下面的兼容性代码修复此 bug:

                                              @@ -158,7 +158,7 @@ if ('ab'.substr(-1) != 'b')

                                              Note: Up to version 3.6, Firefox had a bug which caused substr to return empty result when an explicit undefined value was passed in as the length.

                                              -

                                              相关链接

                                              +

                                              相关链接

                                              • {{jsxref("String.prototype.slice()")}}
                                              • 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

                                                substring() 方法返回一个字符串在开始索引到结束索引之间的一个子集, 或从开始索引直到字符串的末尾的一个子集。

                                                -

                                                语法

                                                +

                                                语法

                                                str.substring(indexStart[, indexEnd])
                                                -

                                                参数

                                                +

                                                参数

                                                indexStart
                                                @@ -26,7 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substring

                                                包含给定字符串的指定部分的新字符串。

                                                -

                                                描述

                                                +

                                                描述

                                                substring 提取从 indexStart 到 indexEnd(不包括)之间的字符。特别地:

                                                @@ -38,9 +38,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substring
                                              • 如果 indexStart 大于 indexEnd,则 substring 的执行效果就像两个参数调换了一样。见下面的例子。
                                              -

                                              示例

                                              +

                                              示例

                                              -

                                              例子:使用 substring

                                              +

                                              例子:使用 substring

                                              下例使用 substring 输出字符串 "Mozilla" 中的字符:

                                              @@ -83,7 +83,7 @@ var anyString = 'Mozilla'; var anyString5 = anyString.substring(anyString.length - 5); console.log(anyString5); -

                                              例子:替换一个字符串的子字符串

                                              +

                                              例子:替换一个字符串的子字符串

                                              下例替换了一个字符串中的子字符串。可以替换单个字符和子字符串。该例结尾调用的函数将 "Brave New World" 变成了 "Brave New Web"。

                                              @@ -186,7 +186,7 @@ replaceString("World", "Web", "Brave New World"); -

                                              相关链接

                                              +

                                              相关链接

                                              • {{jsxref("String.prototype.substr()")}}
                                              • 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 ---
                                                {{JSRef("Global_Objects", "String")}}
                                                -

                                                概述

                                                +

                                                概述

                                                toString() 方法返回指定对象的字符串形式。

                                                -

                                                语法

                                                +

                                                语法

                                                str.toString()
                                                 
                                                @@ -18,13 +18,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/toString

                                                一个表示调用对象的字符串。

                                                -

                                                描述

                                                +

                                                描述

                                                String 对象覆盖了{{jsxref("Global_Objects/Object", "Object")}} 对象的 toString 方法;并没有继承 {{jsxref("Object.toString()")}}。对于 String 对象,toString 方法返回该对象的字符串形式,和 {{jsxref("String.prototype.valueOf()")}} 方法返回值一样。

                                                -

                                                示例

                                                +

                                                示例

                                                -

                                                例子:使用 toString

                                                +

                                                例子:使用 toString

                                                下例输出一个字符串对象(String object)的字符串值:

                                                @@ -116,7 +116,7 @@ alert(x.toString()) // 输出 "Hello world" -

                                                相关链接

                                                +

                                                相关链接

                                                • {{jsxref("Object.prototype.toSource()")}}
                                                • 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

                                                  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 https://github.com/mdn/interactive-examples and send us a pull request.

                                                  -

                                                  语法

                                                  +

                                                  语法

                                                  str.trimEnd();
                                                   str.trimRight();
                                                  @@ -26,7 +26,7 @@ original_slug: Web/JavaScript/Reference/Global_Objects/String/TrimRight

                                                  一个新字符串,表示从调用字串的末(右)端除去空白。

                                                  -

                                                  描述

                                                  +

                                                  描述

                                                  trimEnd() / trimRight()方法移除原字符串右端的连续空白符并返回,trimEnd() / trimRight()方法并不会直接修改原字符串本身。

                                                  @@ -37,7 +37,7 @@ original_slug: Web/JavaScript/Reference/Global_Objects/String/TrimRight
                                                  String.prototype.trimRight.name === "trimEnd";
                                                   
                                                  -

                                                  示例

                                                  +

                                                  示例

                                                  使用trimEnd()

                                                  @@ -77,7 +77,7 @@ console.log(str); // ' foo'

                                                  {{Compat("javascript.builtins.String.trimEnd")}}

                                                  -

                                                  相关链接

                                                  +

                                                  相关链接

                                                  • {{jsxref("String.prototype.trim()")}}
                                                  • 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

                                                    Symbol.for(key) 方法会根据给定的键 key,来从运行时的 symbol 注册表中找到对应的 symbol,如果找到了,则返回它,否则,新建一个与该键关联的 symbol,并放入全局 symbol 注册表中。

                                                    -

                                                    语法

                                                    +

                                                    语法

                                                    Symbol.for(key);
                                                    @@ -26,7 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/for

                                                    返回由给定的 key 找到的 symbol,否则就是返回新创建的 symbol。

                                                    -

                                                    描述

                                                    +

                                                    描述

                                                    Symbol() 不同的是,用 Symbol.for() 方法创建的的 symbol 会被放入一个全局 symbol 注册表中。Symbol.for() 并不是每次都会创建一个新的 symbol,它会首先检查给定的 key 是否已经在注册表中了。假如是,则会直接返回上次存储的那个。否则,它会再新建一个。

                                                    @@ -147,7 +147,7 @@ Symbol.for("mdn.bar"); -

                                                    相关链接

                                                    +

                                                    相关链接

                                                    • {{jsxref("Symbol.keyFor()")}}
                                                    • 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 -

                                                      语法

                                                      +

                                                      语法

                                                      Symbol([description])
                                                      -

                                                      参数

                                                      +

                                                      参数

                                                      description {{optional_inline}}
                                                      可选的,字符串类型。对symbol的描述,可用于调试但不是访问symbol本身。
                                                      -

                                                      描述

                                                      +

                                                      描述

                                                      直接使用Symbol()创建新的symbol类型,并用一个可选的字符串作为其描述。

                                                      @@ -62,7 +62,7 @@ typeof symObj; // "object"

                                                      {{jsxref("Object.getOwnPropertySymbols()")}} 方法让你在查找一个给定对象的符号属性时返回一个symbol类型的数组。注意,每个初始化的对象都是没有自己的symbol属性的,因此这个数组可能为空,除非你已经在对象上设置了symbol属性。

                                                      -

                                                      属性

                                                      +

                                                      属性

                                                      Symbol.length
                                                      @@ -111,7 +111,7 @@ typeof symObj; // "object"
                                                      用于对象的默认描述的字符串值。被 {{jsxref("Object.prototype.toString()")}} 使用。
                                                      -

                                                      方法

                                                      +

                                                      方法

                                                      {{jsxref("Symbol.for()", "Symbol.for(key)")}}
                                                      @@ -120,7 +120,7 @@ typeof symObj; // "object"
                                                      从全局symbol注册表中,为给定的symbol检索一个共享的?symbol key。
                                                      -

                                                      Symbol 原型

                                                      +

                                                      Symbol 原型

                                                      所有 Symbols 继承自 {{jsxref("Symbol.prototype")}}.

                                                      @@ -144,9 +144,9 @@ typeof symObj; // "object"
                                                      返回该 Symbol 对象。
                                            -

                                            示例

                                            +

                                            示例

                                            -

                                            对 symbol 使用 typeof 运算符

                                            +

                                            对 symbol 使用 typeof 运算符

                                             {{jsxref("Operators/typeof", "typeof")}}运算符能帮助你识别 symbol 类型

                                            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 ---
                                            {{JSRef("Global_Objects", "Symbol")}}
                                            -

                                            概述

                                            +

                                            概述

                                            Symbol.keyFor(sym) 方法用来获取全局symbol 注册表中与某个 symbol 关联的键。

                                            -

                                            语法

                                            +

                                            语法

                                            Symbol.keyFor(sym);
                                            @@ -108,7 +108,7 @@ Symbol.keyFor(Symbol.iterator) // undefined -

                                            相关链接

                                            +

                                            相关链接

                                            • {{jsxref("Symbol.prototype.for()")}}
                                            • 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 ---
                                              {{JSRef("Global_Objects", "Symbol")}}
                                              -

                                              概述

                                              +

                                              概述

                                              toString() 方法返回当前 symbol 对象的字符串表示。

                                              -

                                              语法

                                              +

                                              语法

                                              symbol.toString();
                                              -

                                              描述

                                              +

                                              描述

                                              {{jsxref("Symbol")}} 对象拥有自己的 toString 方法,因而遮蔽了原型链上的 {{jsxref("Object.prototype.toString()")}}。

                                              @@ -109,7 +109,7 @@ Symbol.for("foo").toString() // "Symbol(foo)" -

                                              相关链接

                                              +

                                              相关链接

                                              • {{jsxref("Object.prototype.toString()")}}
                                              • 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 ---
                                                {{JSRef("Global_Objects", "Symbol")}}
                                                -

                                                概述

                                                +

                                                概述

                                                valueOf() 方法返回当前 symbol 对象所包含的 symbol 原始值。

                                                -

                                                语法

                                                +

                                                语法

                                                symbol.valueOf();
                                                 
                                                -

                                                描述

                                                +

                                                描述

                                                在 JavaScript 中,虽然大多数类型的对象在某些操作下都会自动的隐式调用自身的 valueOf() 方法或者 toString() 方法来将自己转换成一个原始值,但 symbol 对象不会这么干,symbol 对象无法隐式转换成对应的原始值:

                                                @@ -99,7 +99,7 @@ Object(Symbol("foo")).toString() + "bar"; -

                                                相关链接

                                                +

                                                相关链接

                                                • {{jsxref("Object.prototype.valueOf()")}}
                                                • 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

                                                  SyntaxError 对象代表尝试解析语法上不合法的代码的错误。

                                                  -

                                                  描述

                                                  +

                                                  描述

                                                  当Javascript语言解析代码时,Javascript引擎发现了不符合语法规范的tokens或token顺序时抛出SyntaxError.

                                                  -

                                                  语法

                                                  +

                                                  语法

                                                  new SyntaxError([message[, fileName[, lineNumber]]])
                                                  -

                                                  参数

                                                  +

                                                  参数

                                                  message
                                                  @@ -31,30 +31,30 @@ translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError
                                                  可选的. 包含引发异常的代码的行号
                                                  -

                                                  属性

                                                  +

                                                  属性

                                                  {{jsxref("SyntaxError.prototype")}}
                                                  允许SyntaxError对象添加属性.
                                                  -

                                                  方法

                                                  +

                                                  方法

                                                  全局 SyntaxError 自身不包含任何方法, 但从原型链中继承了一些方法.

                                                  -

                                                  SyntaxError 实例

                                                  +

                                                  SyntaxError 实例

                                                  -

                                                  属性

                                                  +

                                                  属性

                                                  {{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError/prototype', '属性')}}
                                                  -

                                                  方法

                                                  +

                                                  方法

                                                  {{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError/prototype', '方法')}}
                                                  -

                                                  示例

                                                  +

                                                  示例

                                                  -

                                                  捕获 SyntaxError

                                                  +

                                                  捕获 SyntaxError

                                                  try {
                                                     eval('hoo bar');
                                                  @@ -69,7 +69,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError
                                                   }
                                                   
                                                  -

                                                  创建 SyntaxError

                                                  +

                                                  创建 SyntaxError

                                                  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
                                                   
                                                   

                                                  TypeError(类型错误) 对象用来表示值的类型非预期类型时发生的错误。

                                                  -

                                                  语法

                                                  +

                                                  语法

                                                  new TypeError([message[, fileName[, lineNumber]]])
                                                  -

                                                  参数

                                                  +

                                                  参数

                                                  message 消息
                                                  @@ -31,34 +31,34 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypeError
                                                  可选. 引起该异常的代码的行号。
                                                  -

                                                  描述

                                                  +

                                                  描述

                                                  当传入函数的操作数参数的类型并非操作符或函数所预期的类型时,将抛出一个 TypeError 类型错误。

                                                  -

                                                  属性

                                                  +

                                                  属性

                                                  {{jsxref("TypeError.prototype")}}
                                                  允许为一个 TypeError 类型错误附加属性。
                                                  -

                                                  方法

                                                  +

                                                  方法

                                                  全局 TypeError 不包含任何方法,不过,它将从原型链中继承一些方法。

                                                  -

                                                  TypeError 类型错误实例

                                                  +

                                                  TypeError 类型错误实例

                                                  -

                                                  属性

                                                  +

                                                  属性

                                                  {{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypeError/prototype', '属性')}}
                                                  -

                                                  方法

                                                  +

                                                  方法

                                                  {{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypeError/prototype', '方法')}}
                                                  -

                                                  示例

                                                  +

                                                  示例

                                                  -

                                                  示例: 捕获类型错误

                                                  +

                                                  示例: 捕获类型错误

                                                  try {
                                                     null.f();
                                                  @@ -73,7 +73,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypeError
                                                   }
                                                   
                                                  -

                                                  示例: 创建一个类型错误

                                                  +

                                                  示例: 创建一个类型错误

                                                  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]]);
                                                  从可变长度的参数创建一个新的 Uint32Array 。请参考 {{jsxref("Array.of()")}}.
                                        -

                                        Uint32Array 原型

                                        +

                                        Uint32Array 原型

                                        所有 Uint32Array 对象继承自 {{jsxref("TypedArray.prototype", "%TypedArray%.prototype")}}.

                                        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]]);
                                        通过一个可变数目的参数创建一个新的Uint8Array数组,可参见{{jsxref("Array.of()")}}.
                                        -

                                        Uint8Array 原型声明

                                        +

                                        Uint8Array 原型声明

                                        所有的Uint8Array对象继承自 {{jsxref("TypedArray.prototype", "%TypedArray%.prototype")}}.

                                        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 -

                                        语法

                                        +

                                        语法

                                        undefined 
                                        -

                                        描述

                                        +

                                        描述

                                        undefined全局对象的一个属性。也就是说,它是全局作用域的一个变量。undefined的最初值就是原始数据类型{{Glossary("Undefined", "undefined")}}

                                        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 ---
                                        {{JSRef("Global_Objects", "WeakMap")}}
                                        -

                                        概述

                                        +

                                        概述

                                        delete() 方法可以从一个 WeakMap 对象中删除指定的元素。

                                        -

                                        语法

                                        +

                                        语法

                                        wm.delete(key);
                                        @@ -24,7 +24,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/delete

                                        如果成功删除,返回 true,否则返回 false

                                        -

                                        示例

                                        +

                                        示例

                                        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);

                                        在此,在第一次运行时创建WeakSet,并将其与每个后续函数调用一起传递(使用内部参数_refs)。 对象的数量或它们的遍历顺序无关紧要,因此,WeakSet比{{jsxref("Set")}}更适合(和执行)跟踪对象引用,尤其是在涉及大量对象时。

                                        -

                                        属性

                                        +

                                        属性

                                        WeakSet.length
                                        @@ -97,7 +97,7 @@ execRecursively(obj => console.log(obj), foo);
                                        表示WeakSet构造函数的原型。 允许向所有WeakSet对象添加属性。
                                        -

                                        WeakSet 实例

                                        +

                                        WeakSet 实例

                                        所有 WeakSet 实例都继承自 {{jsxref("WeakSet.prototype")}}.

                                        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) { -

                                        Browser compatibility

                                        +

                                        Browser compatibility

                                        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 -

                                        浏览器兼容性

                                        +

                                        浏览器兼容性

                                        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')) -

                                        Browser compatibility

                                        +

                                        Browser compatibility

                                        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 } }) -

                                        浏览器兼容性

                                        +

                                        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) -

                                        浏览器兼容性

                                        +

                                        浏览器兼容性

                                        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 -

                                        浏览器兼容性

                                        +

                                        {{Compat("javascript.builtins.WebAssembly.Instance")}}

                                        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) { -

                                        浏览器兼容性

                                        +

                                        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) -

                                        Browser compatibility

                                        +

                                        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 -

                                        浏览器兼容性

                                        +

                                        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 -

                                        浏览器兼容性

                                        +

                                        浏览器兼容性

                                        {{Compat("javascript.builtins.WebAssembly.Module")}}

                                        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 -

                                        浏览器兼容性

                                        +

                                        浏览器兼容性

                                        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" -

                                        浏览器兼容性

                                        +

                                        浏览器兼容性

                                        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 -

                                        Browser compatibility

                                        +

                                        Browser compatibility

                                        -- cgit v1.2.3-54-g00ecf