From d44f5032d0f53256b2d5aef505d6b593fd3cd158 Mon Sep 17 00:00:00 2001 From: Irvin Date: Wed, 16 Feb 2022 02:14:18 +0800 Subject: fix yari h2m dry run errors (zh-CN) --- .../reference/classes/constructor/index.html | 2 +- .../reference/classes/extends/index.html | 2 +- .../web/javascript/reference/classes/index.html | 16 +- .../classes/public_class_fields/index.html | 4 +- .../javascript/reference/classes/static/index.html | 2 +- .../the_legacy_iterator_protocol/index.html | 4 +- .../reference/errors/bad_octal/index.html | 2 +- .../errors/deprecated_source_map_pragma/index.html | 50 +- .../for-each-in_loops_are_deprecated/index.html | 57 +- .../reference/errors/getter_only/index.html | 2 +- .../errors/missing_formal_parameter/index.html | 4 +- .../missing_semicolon_before_statement/index.html | 4 +- .../reference/errors/not_defined/index.html | 2 +- .../functions/arguments/callee/index.html | 2 +- .../reference/functions/arguments/index.html | 26 +- .../reference/functions/arrow_functions/index.html | 2 +- .../javascript/reference/functions/get/index.html | 4 +- .../web/javascript/reference/functions/index.html | 24 +- .../functions/method_definitions/index.html | 8 +- .../global_objects/array/concat/index.html | 2 +- .../global_objects/array/every/index.html | 2 +- .../reference/global_objects/array/flat/index.html | 2 +- .../global_objects/array/foreach/index.html | 10 +- .../global_objects/array/includes/index.html | 6 +- .../reference/global_objects/array/index.md | 6 +- .../global_objects/array/indexof/index.html | 2 +- .../reference/global_objects/array/join/index.html | 12 +- .../global_objects/array/length/index.html | 4 +- .../global_objects/array/reduce/index.html | 6 +- .../global_objects/array/reduceright/index.html | 30 +- .../global_objects/array/slice/index.html | 4 +- .../reference/global_objects/array/some/index.html | 2 +- .../reference/global_objects/array/sort/index.html | 2 +- .../global_objects/array/values/index.html | 8 +- .../global_objects/asyncfunction/index.html | 2 +- .../global_objects/atomics/notify/index.html | 2 +- .../global_objects/atomics/wait/index.html | 2 +- .../global_objects/bigint/bigint/index.html | 4 +- .../reference/global_objects/bigint/index.html | 4 +- .../global_objects/bigint64array/index.html | 23 +- .../reference/global_objects/boolean/index.html | 4 +- .../global_objects/dataview/getfloat32/index.html | 8 +- .../global_objects/dataview/getfloat64/index.html | 8 +- .../global_objects/dataview/getint16/index.html | 8 +- .../global_objects/dataview/getint32/index.html | 8 +- .../global_objects/dataview/getint8/index.html | 4 +- .../global_objects/dataview/getuint16/index.html | 8 +- .../global_objects/dataview/getuint32/index.html | 8 +- .../global_objects/dataview/getuint8/index.html | 4 +- .../global_objects/dataview/setint8/index.html | 9 +- .../reference/global_objects/date/date/index.html | 4 +- .../global_objects/date/getdate/index.html | 4 +- .../global_objects/date/getday/index.html | 8 +- .../global_objects/date/gethours/index.html | 4 +- .../global_objects/date/getmilliseconds/index.html | 4 +- .../global_objects/date/getminutes/index.html | 4 +- .../global_objects/date/getmonth/index.html | 4 +- .../global_objects/date/getseconds/index.html | 8 +- .../date/gettimezoneoffset/index.html | 2 +- .../reference/global_objects/date/index.html | 18 +- .../reference/global_objects/date/parse/index.html | 14 +- .../global_objects/date/setfullyear/index.html | 4 +- .../global_objects/date/settime/index.html | 7 +- .../global_objects/decodeuricomponent/index.html | 80 +-- .../reference/global_objects/encodeuri/index.html | 93 +-- .../global_objects/error/columnnumber/index.html | 52 +- .../global_objects/error/filename/index.html | 54 +- .../reference/global_objects/error/index.html | 44 +- .../global_objects/error/message/index.html | 75 +-- .../reference/global_objects/error/name/index.html | 75 +-- .../global_objects/error/tosource/index.html | 2 +- .../global_objects/error/tostring/index.html | 79 +-- .../reference/global_objects/escape/index.html | 50 +- .../global_objects/finalizationregistry/index.html | 2 +- .../global_objects/float32array/index.html | 69 +- .../global_objects/float64array/index.html | 69 +- .../global_objects/function/apply/index.html | 12 +- .../global_objects/function/arguments/index.html | 52 +- .../global_objects/function/bind/index.html | 2 +- .../global_objects/function/call/index.html | 6 +- .../global_objects/function/displayname/index.html | 56 +- .../global_objects/function/name/index.html | 6 +- .../global_objects/generator/next/index.html | 56 +- .../global_objects/generator/throw/index.html | 52 +- .../global_objects/generatorfunction/index.html | 2 +- .../reference/global_objects/infinity/index.html | 2 +- .../reference/global_objects/int16array/index.html | 69 +- .../reference/global_objects/int32array/index.html | 67 +- .../reference/global_objects/int8array/index.html | 67 +- .../global_objects/internalerror/index.html | 50 +- .../global_objects/intl/datetimeformat/index.html | 55 +- .../global_objects/intl/numberformat/index.html | 8 +- .../global_objects/intl/pluralrules/index.html | 4 +- .../reference/global_objects/isfinite/index.html | 26 +- .../reference/global_objects/isnan/index.html | 2 +- .../global_objects/json/stringify/index.html | 8 +- .../global_objects/map/@@tostringtag/index.html | 54 +- .../reference/global_objects/map/delete/index.html | 2 +- .../reference/global_objects/map/has/index.html | 50 +- .../reference/global_objects/map/index.html | 18 +- .../reference/global_objects/map/size/index.html | 4 +- .../reference/global_objects/map/values/index.html | 50 +- .../reference/global_objects/math/abs/index.html | 50 +- .../reference/global_objects/math/acos/index.html | 51 +- .../reference/global_objects/math/asin/index.html | 51 +- .../reference/global_objects/math/atan/index.html | 51 +- .../reference/global_objects/math/atan2/index.html | 50 +- .../reference/global_objects/math/atanh/index.html | 50 +- .../reference/global_objects/math/cbrt/index.html | 52 +- .../reference/global_objects/math/ceil/index.html | 9 +- .../reference/global_objects/math/cos/index.html | 51 +- .../reference/global_objects/math/cosh/index.html | 50 +- .../reference/global_objects/math/e/index.html | 51 +- .../reference/global_objects/math/exp/index.html | 51 +- .../reference/global_objects/math/expm1/index.html | 50 +- .../reference/global_objects/math/floor/index.html | 61 +- .../global_objects/math/fround/index.html | 52 +- .../reference/global_objects/math/imul/index.html | 52 +- .../reference/global_objects/math/index.html | 4 +- .../reference/global_objects/math/ln10/index.html | 51 +- .../reference/global_objects/math/ln2/index.html | 51 +- .../reference/global_objects/math/log/index.html | 50 +- .../reference/global_objects/math/log10/index.html | 50 +- .../global_objects/math/log10e/index.html | 51 +- .../reference/global_objects/math/log1p/index.html | 50 +- .../reference/global_objects/math/log2/index.html | 50 +- .../reference/global_objects/math/log2e/index.html | 51 +- .../reference/global_objects/math/min/index.html | 56 +- .../reference/global_objects/math/pi/index.html | 52 +- .../global_objects/math/random/index.html | 8 +- .../reference/global_objects/math/round/index.html | 57 +- .../reference/global_objects/math/sign/index.html | 52 +- .../reference/global_objects/math/sinh/index.html | 54 +- .../global_objects/math/sqrt1_2/index.html | 51 +- .../reference/global_objects/math/sqrt2/index.html | 51 +- .../reference/global_objects/math/tan/index.html | 51 +- .../global_objects/number/epsilon/index.html | 50 +- .../number/max_safe_integer/index.html | 50 +- .../global_objects/number/max_value/index.html | 50 +- .../global_objects/number/min_value/index.html | 51 +- .../reference/global_objects/number/nan/index.html | 50 +- .../number/negative_infinity/index.html | 53 +- .../global_objects/number/parsefloat/index.html | 56 +- .../number/positive_infinity/index.html | 50 +- .../global_objects/number/toexponential/index.html | 50 +- .../global_objects/number/tofixed/index.html | 2 +- .../number/tolocalestring/index.html | 2 +- .../global_objects/number/toprecision/index.html | 50 +- .../global_objects/number/tosource/index.html | 51 +- .../global_objects/number/tostring/index.html | 52 +- .../global_objects/number/valueof/index.html | 50 +- .../object/__definegetter__/index.html | 54 +- .../object/__definesetter__/index.html | 54 +- .../object/__lookupgetter__/index.html | 50 +- .../object/__lookupsetter__/index.html | 50 +- .../global_objects/object/assign/index.html | 4 +- .../object/defineproperty/index.html | 8 +- .../global_objects/object/entries/index.html | 4 +- .../global_objects/object/freeze/index.html | 2 +- .../object/getownpropertydescriptors/index.html | 2 +- .../object/getownpropertysymbols/index.html | 8 +- .../object/getprototypeof/index.html | 19 +- .../global_objects/object/isextensible/index.html | 48 +- .../global_objects/object/isfrozen/index.html | 8 +- .../global_objects/object/isprototypeof/index.html | 54 +- .../object/preventextensions/index.html | 8 +- .../global_objects/object/proto/index.html | 4 +- .../object/setprototypeof/index.html | 2 +- .../global_objects/object/tostring/index.html | 4 +- .../global_objects/object/valueof/index.html | 4 +- .../reference/global_objects/parsefloat/index.html | 8 +- .../reference/global_objects/parseint/index.html | 9 +- .../global_objects/promise/any/index.html | 4 +- .../global_objects/promise/finally/index.html | 2 +- .../reference/global_objects/promise/index.html | 6 +- .../global_objects/promise/reject/index.html | 4 +- .../global_objects/promise/resolve/index.html | 8 +- .../global_objects/promise/then/index.html | 2 +- .../proxy/proxy/defineproperty/index.html | 50 +- .../proxy/proxy/deleteproperty/index.html | 50 +- .../global_objects/proxy/proxy/get/index.html | 50 +- .../proxy/getownpropertydescriptor/index.html | 50 +- .../global_objects/proxy/proxy/has/index.html | 52 +- .../global_objects/proxy/proxy/ownkeys/index.html | 52 +- .../global_objects/proxy/proxy/set/index.html | 2 +- .../reference/global_objects/rangeerror/index.html | 50 +- .../global_objects/referenceerror/index.html | 50 +- .../global_objects/reflect/construct/index.html | 52 +- .../reflect/defineproperty/index.html | 4 +- .../reflect/deleteproperty/index.html | 50 +- .../reflect/getownpropertydescriptor/index.html | 50 +- .../global_objects/reflect/has/index.html | 50 +- .../global_objects/reflect/isextensible/index.html | 50 +- .../global_objects/regexp/@@search/index.html | 50 +- .../global_objects/regexp/@@species/index.html | 50 +- .../global_objects/regexp/@@split/index.html | 50 +- .../global_objects/regexp/compile/index.html | 50 +- .../global_objects/regexp/exec/index.html | 12 +- .../global_objects/regexp/flags/index.html | 50 +- .../global_objects/regexp/global/index.html | 51 +- .../global_objects/regexp/ignorecase/index.html | 51 +- .../reference/global_objects/regexp/index.html | 4 +- .../global_objects/regexp/input/index.html | 50 +- .../global_objects/regexp/lastindex/index.html | 53 +- .../global_objects/regexp/lastmatch/index.html | 50 +- .../global_objects/regexp/lastparen/index.html | 50 +- .../global_objects/regexp/leftcontext/index.html | 50 +- .../global_objects/regexp/multiline/index.html | 51 +- .../reference/global_objects/regexp/n/index.html | 54 +- .../global_objects/regexp/regexp/index.html | 3 +- .../global_objects/regexp/rightcontext/index.html | 50 +- .../global_objects/regexp/source/index.html | 52 +- .../global_objects/regexp/tostring/index.html | 51 +- .../global_objects/regexp/unicode/index.html | 52 +- .../reference/global_objects/set/clear/index.html | 50 +- .../reference/global_objects/set/delete/index.html | 50 +- .../global_objects/set/entries/index.html | 52 +- .../global_objects/set/foreach/index.html | 50 +- .../reference/global_objects/set/has/index.html | 52 +- .../global_objects/sharedarraybuffer/index.html | 4 +- .../global_objects/string/@@iterator/index.html | 52 +- .../global_objects/string/anchor/index.html | 59 +- .../reference/global_objects/string/big/index.html | 52 +- .../global_objects/string/blink/index.html | 50 +- .../global_objects/string/bold/index.html | 50 +- .../global_objects/string/charat/index.html | 50 +- .../global_objects/string/charcodeat/index.html | 4 +- .../global_objects/string/codepointat/index.html | 50 +- .../global_objects/string/fixed/index.html | 50 +- .../global_objects/string/fontcolor/index.html | 56 +- .../global_objects/string/fontsize/index.html | 52 +- .../global_objects/string/fromcodepoint/index.html | 9 +- .../global_objects/string/includes/index.html | 7 +- .../reference/global_objects/string/index.html | 60 +- .../global_objects/string/indexof/index.html | 4 +- .../global_objects/string/italics/index.html | 52 +- .../global_objects/string/lastindexof/index.html | 59 +- .../global_objects/string/length/index.html | 50 +- .../global_objects/string/match/index.html | 71 +- .../global_objects/string/matchall/index.html | 4 +- .../global_objects/string/padstart/index.html | 4 +- .../global_objects/string/repeat/index.html | 2 +- .../global_objects/string/replace/index.html | 8 +- .../global_objects/string/replaceall/index.html | 12 +- .../global_objects/string/small/index.html | 50 +- .../global_objects/string/split/index.html | 8 +- .../global_objects/string/strike/index.html | 50 +- .../reference/global_objects/string/sub/index.html | 50 +- .../global_objects/string/substr/index.html | 54 +- .../global_objects/string/substring/index.html | 50 +- .../reference/global_objects/string/sup/index.html | 50 +- .../string/tolocalelowercase/index.html | 50 +- .../global_objects/string/tolowercase/index.html | 54 +- .../global_objects/string/tosource/index.html | 52 +- .../global_objects/string/tostring/index.html | 50 +- .../global_objects/string/trimend/index.html | 2 +- .../global_objects/string/trimstart/index.html | 2 +- .../reference/global_objects/symbol/for/index.html | 50 +- .../reference/global_objects/symbol/index.html | 8 +- .../global_objects/symbol/keyfor/index.html | 54 +- .../global_objects/symbol/search/index.html | 50 +- .../global_objects/symbol/split/index.html | 50 +- .../global_objects/symbol/toprimitive/index.html | 9 +- .../global_objects/symbol/tosource/index.html | 54 +- .../global_objects/symbol/tostring/index.html | 50 +- .../global_objects/symbol/tostringtag/index.html | 50 +- .../global_objects/symbol/valueof/index.html | 50 +- .../global_objects/syntaxerror/index.html | 50 +- .../typedarray/@@iterator/index.html | 50 +- .../global_objects/typedarray/@@species/index.html | 50 +- .../global_objects/typedarray/buffer/index.html | 50 +- .../typedarray/bytelength/index.html | 50 +- .../typedarray/byteoffset/index.html | 50 +- .../typedarray/bytes_per_element/index.html | 52 +- .../typedarray/copywithin/index.html | 52 +- .../global_objects/typedarray/entries/index.html | 50 +- .../global_objects/typedarray/every/index.html | 52 +- .../global_objects/typedarray/fill/index.html | 50 +- .../global_objects/typedarray/filter/index.html | 50 +- .../global_objects/typedarray/find/index.html | 50 +- .../global_objects/typedarray/findindex/index.html | 50 +- .../global_objects/typedarray/foreach/index.html | 8 +- .../global_objects/typedarray/from/index.html | 2 +- .../global_objects/typedarray/includes/index.html | 52 +- .../global_objects/typedarray/indexof/index.html | 52 +- .../global_objects/typedarray/join/index.html | 52 +- .../global_objects/typedarray/keys/index.html | 52 +- .../typedarray/lastindexof/index.html | 52 +- .../global_objects/typedarray/length/index.html | 50 +- .../global_objects/typedarray/map/index.html | 50 +- .../global_objects/typedarray/name/index.html | 54 +- .../global_objects/typedarray/of/index.html | 52 +- .../global_objects/typedarray/reduce/index.html | 52 +- .../typedarray/reduceright/index.html | 52 +- .../global_objects/typedarray/reverse/index.html | 52 +- .../global_objects/typedarray/set/index.html | 50 +- .../global_objects/typedarray/some/index.html | 2 +- .../global_objects/typedarray/sort/index.html | 50 +- .../global_objects/typedarray/tostring/index.html | 50 +- .../global_objects/typedarray/values/index.html | 52 +- .../global_objects/uint8clampedarray/index.html | 84 +-- .../reference/global_objects/undefined/index.html | 6 +- .../reference/global_objects/unescape/index.html | 12 +- .../reference/global_objects/uneval/index.html | 8 +- .../global_objects/weakmap/clear/index.html | 56 +- .../global_objects/weakmap/delete/index.html | 48 +- .../global_objects/weakmap/get/index.html | 48 +- .../global_objects/weakmap/has/index.html | 50 +- .../reference/global_objects/weakref/index.html | 2 +- .../global_objects/weakset/add/index.html | 48 +- .../global_objects/weakset/delete/index.html | 48 +- .../global_objects/weakset/has/index.html | 48 +- .../global_objects/webassembly/global/index.html | 10 +- .../global_objects/webassembly/index.html | 2 +- .../global_objects/webassembly/instance/index.html | 7 +- .../webassembly/instantiate/index.html | 14 +- .../webassembly/instantiatestreaming/index.html | 8 +- .../global_objects/webassembly/memory/index.html | 10 +- .../global_objects/webassembly/module/index.html | 2 +- .../global_objects/webassembly/table/index.html | 2 +- files/zh-cn/web/javascript/reference/index.html | 713 ++++++++++----------- .../reference/lexical_grammar/index.html | 8 +- .../reference/operators/await/index.html | 54 +- .../reference/operators/bitwise_and/index.html | 6 +- .../reference/operators/bitwise_not/index.html | 4 +- .../reference/operators/bitwise_or/index.html | 6 +- .../reference/operators/bitwise_xor/index.html | 6 +- .../reference/operators/comma_operator/index.html | 2 +- .../operators/conditional_operator/index.html | 2 +- .../reference/operators/delete/index.html | 4 +- .../operators/destructuring_assignment/index.html | 4 +- .../reference/operators/function/index.html | 50 +- .../web/javascript/reference/operators/index.html | 8 +- .../reference/operators/instanceof/index.html | 8 +- .../reference/operators/logical_or/index.html | 4 +- .../javascript/reference/operators/new/index.html | 2 +- .../operators/optional_chaining/index.html | 8 +- .../operators/property_accessors/index.html | 2 +- .../javascript/reference/operators/this/index.html | 22 +- .../reference/operators/typeof/index.html | 6 +- .../reference/statements/async_function/index.html | 17 +- .../reference/statements/break/index.html | 4 +- .../reference/statements/class/index.html | 1 + .../reference/statements/continue/index.html | 6 +- .../reference/statements/debugger/index.html | 4 +- .../reference/statements/do...while/index.html | 2 +- .../reference/statements/export/index.html | 4 +- .../reference/statements/for-await...of/index.html | 4 +- .../reference/statements/for...in/index.html | 2 +- .../javascript/reference/statements/for/index.html | 2 +- .../reference/statements/function/index.html | 8 +- .../reference/statements/import/index.html | 2 +- .../reference/statements/return/index.html | 2 +- .../reference/statements/with/index.html | 6 +- .../javascript/reference/strict_mode/index.html | 6 +- .../transitioning_to_strict_mode/index.html | 4 +- .../reference/template_literals/index.html | 8 +- 357 files changed, 1174 insertions(+), 10299 deletions(-) (limited to 'files/zh-cn/web/javascript/reference') diff --git a/files/zh-cn/web/javascript/reference/classes/constructor/index.html b/files/zh-cn/web/javascript/reference/classes/constructor/index.html index 2264eaa6a8..73b4ac2507 100644 --- a/files/zh-cn/web/javascript/reference/classes/constructor/index.html +++ b/files/zh-cn/web/javascript/reference/classes/constructor/index.html @@ -118,7 +118,7 @@ console.log(newInstance.name); //Polygon

浏览器兼容

-

{{Compat("javascript.classes.constructor")}}

+{{Compat}}

参阅

diff --git a/files/zh-cn/web/javascript/reference/classes/extends/index.html b/files/zh-cn/web/javascript/reference/classes/extends/index.html index 37223f83ee..f01e3f8062 100644 --- a/files/zh-cn/web/javascript/reference/classes/extends/index.html +++ b/files/zh-cn/web/javascript/reference/classes/extends/index.html @@ -94,7 +94,7 @@ new nullExtends(); //ReferenceError: this is not defined

浏览器兼容

-

{{Compat("javascript.classes.extends")}}

+{{Compat}}

扩展阅读

diff --git a/files/zh-cn/web/javascript/reference/classes/index.html b/files/zh-cn/web/javascript/reference/classes/index.html index 643b672fe7..8b2acf82d2 100644 --- a/files/zh-cn/web/javascript/reference/classes/index.html +++ b/files/zh-cn/web/javascript/reference/classes/index.html @@ -66,8 +66,8 @@ let Rectangle = class Rectangle2 { console.log(Rectangle.name); // 输出: "Rectangle2" -
-

注意: 类表达式也同样受到类声明部分中提到的类型提升的限制。

+
+

备注: 类表达式也同样受到类声明部分中提到的类型提升的限制。

类体和方法定义

@@ -205,8 +205,8 @@ Rectangle.prototype.prototypeWidth = 25;

字段声明

-
-

公共和私有字段声明是JavaScript标准委员会TC39提出的实验性功能(第3阶段)。浏览器中的支持是有限的,但是可以通过Babel等系统构建后使用此功能。

+
+

警告:公共和私有字段声明是JavaScript标准委员会TC39提出的实验性功能(第3阶段)。浏览器中的支持是有限的,但是可以通过Babel等系统构建后使用此功能。

公有字段声明

@@ -243,8 +243,8 @@ Rectangle.prototype.prototypeWidth = 25;

从类外部引用私有字段是错误的。它们只能在类里面中读取或写入。通过定义在类外部不可见的内容,可以确保类的用户不会依赖于内部,因为内部可能在不同版本之间发生变化。

-
-

私有字段仅能在字段声明中预先定义。 

+
+

备注:私有字段仅能在字段声明中预先定义。 

私有字段不能通过在之后赋值来创建它们,这种方式只适用普通属性。

@@ -424,9 +424,7 @@ class Bar extends calculatorMixin(randomizerMixin(Foo)) { }

浏览器兼容

- - -

{{Compat("javascript.classes")}}

+{{Compat}}

重新运行一个类定义

diff --git a/files/zh-cn/web/javascript/reference/classes/public_class_fields/index.html b/files/zh-cn/web/javascript/reference/classes/public_class_fields/index.html index 64ce546ea0..33e7462617 100644 --- a/files/zh-cn/web/javascript/reference/classes/public_class_fields/index.html +++ b/files/zh-cn/web/javascript/reference/classes/public_class_fields/index.html @@ -10,7 +10,9 @@ original_slug: Web/JavaScript/Reference/Classes/Class_elements ---
{{JsSidebar("Classes")}}
-
公有(public)和私有(private)字段声明是一个JavaScript标准委员会TC39提议的试验性功能 (第3阶段)。这项功能在浏览器中的支持还受限,但你可以通过Babel等构建系统来使用它。参见下面的兼容性信息
+
+

备注:公有(public)和私有(private)字段声明是一个JavaScript标准委员会TC39提议的试验性功能 (第3阶段)。这项功能在浏览器中的支持还受限,但你可以通过Babel等构建系统来使用它。参见下面的兼容性信息

+

公有字段

diff --git a/files/zh-cn/web/javascript/reference/classes/static/index.html b/files/zh-cn/web/javascript/reference/classes/static/index.html index 1f6d544415..2898a2ffee 100644 --- a/files/zh-cn/web/javascript/reference/classes/static/index.html +++ b/files/zh-cn/web/javascript/reference/classes/static/index.html @@ -125,7 +125,7 @@ console.log(tp.tripple());// 'tp.tripple 不是一个函数'.

浏览器兼容

-

{{Compat("javascript.classes.static")}}

+{{Compat}}

相关链接

diff --git a/files/zh-cn/web/javascript/reference/deprecated_and_obsolete_features/the_legacy_iterator_protocol/index.html b/files/zh-cn/web/javascript/reference/deprecated_and_obsolete_features/the_legacy_iterator_protocol/index.html index 75308950a2..540d062f05 100644 --- a/files/zh-cn/web/javascript/reference/deprecated_and_obsolete_features/the_legacy_iterator_protocol/index.html +++ b/files/zh-cn/web/javascript/reference/deprecated_and_obsolete_features/the_legacy_iterator_protocol/index.html @@ -14,7 +14,9 @@ translation_of: >- ---
{{jsSidebar("More")}}
-
非标准。旧式迭代器协议是一个特定于 SpiderMonkey 的功能,在 Firefox 58+ 中删除。对于面向未来的用法,请考虑使用 for..of 循环与迭代协议
+
+

警告:非标准。旧式迭代器协议是一个特定于 SpiderMonkey 的功能,在 Firefox 58+ 中删除。对于面向未来的用法,请考虑使用 for..of 循环与迭代协议

+

废弃的 Firefox 专用迭代器协议

diff --git a/files/zh-cn/web/javascript/reference/errors/bad_octal/index.html b/files/zh-cn/web/javascript/reference/errors/bad_octal/index.html index 2f9b5d477e..ff60730174 100644 --- a/files/zh-cn/web/javascript/reference/errors/bad_octal/index.html +++ b/files/zh-cn/web/javascript/reference/errors/bad_octal/index.html @@ -27,7 +27,7 @@ Warning: SyntaxError: 09 is not a legal ECMA-262 octal constant.

请注意,不推荐使用八进制字面值和八进制转义序列,并会产生另外的弃用警告。 在 ECMAScript 6 和更高版本里,语法使用前导零后跟小写或大写拉丁字母“O”(0o或0O)。更多信息请查看 lexical grammar

-

注意:现在仅 firefox 会产生此错误。

+

备注:现在仅 firefox 会产生此错误。

示例

diff --git a/files/zh-cn/web/javascript/reference/errors/deprecated_source_map_pragma/index.html b/files/zh-cn/web/javascript/reference/errors/deprecated_source_map_pragma/index.html index 42339a4e85..074e964160 100644 --- a/files/zh-cn/web/javascript/reference/errors/deprecated_source_map_pragma/index.html +++ b/files/zh-cn/web/javascript/reference/errors/deprecated_source_map_pragma/index.html @@ -51,55 +51,7 @@ Warning: SyntaxError: Using //@ to indicate sourceMappingURL pragmas is deprecat

浏览器兼容性

-

{{CompatibilityTable}}

- -
- - - - - - - - - - - - - - - - - - - -
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
New syntax{{CompatVersionUnknown}}{{ CompatGeckoDesktop(24) }}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
-
- -
- - - - - - - - - - - - - - - - - - - - - -
FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
New syntax{{CompatUnknown}}{{CompatUnknown}}{{ CompatGeckoMobile(24) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
-
+{{Compat}}

相关

diff --git a/files/zh-cn/web/javascript/reference/errors/for-each-in_loops_are_deprecated/index.html b/files/zh-cn/web/javascript/reference/errors/for-each-in_loops_are_deprecated/index.html index 351be47a9d..ba17973172 100644 --- a/files/zh-cn/web/javascript/reference/errors/for-each-in_loops_are_deprecated/index.html +++ b/files/zh-cn/web/javascript/reference/errors/for-each-in_loops_are_deprecated/index.html @@ -29,12 +29,14 @@ translation_of: Web/JavaScript/Reference/Errors/For-each-in_loops_are_deprecated

不赞成这么使用

-

var object = { a: 10, b: 20 };

+

警告:

+
var object = { a: 10, b: 20 };
-

for each (var x in object) {
-   console.log(x);        // 10
-                          // 20
- }

+
for each (var x in object) {
+   console.log(x);        // 10
+                          // 20
+ }
+

替换语法

@@ -67,13 +69,14 @@ for (var x of Object.values(object)) {

不赞成这么使用

-

var array = [10, 20, 30];

- -

for each (var x in array) {
-   console.log(x);        // 10
-                          // 20
-                          // 30
- }

+

警告:

+
var array = [10, 20, 30];
+ +
for each (var x in array) {
+   console.log(x);        // 10
+                          // 20
+                          // 30
+ }

替换语法

@@ -96,15 +99,16 @@ for (var x of array) {

不赞成这么使用

-

function func(array) {
-   for each (var x in array) {
-     console.log(x);
-   }
- }
- func([10, 20]);        // 10
-                        // 20
- func(null);            // prints nothing
- func(undefined);       // prints nothing

+

警告:

+
function func(array) {
+   for each (var x in array) {
+     console.log(x);
+   }
+ }
+ func([10, 20]);        // 10
+                        // 20
+ func(null);            // prints nothing
+ func(undefined);       // prints nothing

替换语法

@@ -131,12 +135,13 @@ func(undefined); // prints nothing

 不赞成使用{{jsxref("Statements/for_each...in", "for each...in")}}和{{jsxref("Iterator")}} 对象来遍历指定对象的键值对.

-

var object = { a: 10, b: 20 };

+

警告:

+
var object = { a: 10, b: 20 };
-

for each (var [key, value] in Iterator(object)) {
-   console.log(key, value);  // "a", 10
-                             // "b", 20
- }

+
for each (var [key, value] in Iterator(object)) {
+   console.log(key, value);  // "a", 10
+                             // "b", 20
+ }

替换语法

diff --git a/files/zh-cn/web/javascript/reference/errors/getter_only/index.html b/files/zh-cn/web/javascript/reference/errors/getter_only/index.html index 0636f30eea..0beef8d006 100644 --- a/files/zh-cn/web/javascript/reference/errors/getter_only/index.html +++ b/files/zh-cn/web/javascript/reference/errors/getter_only/index.html @@ -48,7 +48,7 @@ arc.temperature = 30;

至于修复问题的方法,可以将第 16 行的代码移除,因为它试图为 temperature 属性赋值,或者是为它添加一个 setter 特性,就像下面这样:

-
"use strict";
+
"use strict";
 
 function Archiver() {
   var temperature = null;
diff --git a/files/zh-cn/web/javascript/reference/errors/missing_formal_parameter/index.html b/files/zh-cn/web/javascript/reference/errors/missing_formal_parameter/index.html
index 9d8a069258..1528fbe00e 100644
--- a/files/zh-cn/web/javascript/reference/errors/missing_formal_parameter/index.html
+++ b/files/zh-cn/web/javascript/reference/errors/missing_formal_parameter/index.html
@@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Errors/Missing_formal_parameter
 
 

在构造一个函数的时候,函数参数必须为标记符。下面列举的函数声明都是无效的,因为它们在参数部分使用的是数值:

-
function square(3) {
+
function square(3) {
   return number * number;
 };
 // SyntaxError: missing formal parameter
@@ -47,7 +47,7 @@ function log({ obj: "value"}) {
 
 

需要在函数声明中使用标记符:

-
function square(number) {
+
function square(number) {
   return number * number;
 };
 
diff --git a/files/zh-cn/web/javascript/reference/errors/missing_semicolon_before_statement/index.html b/files/zh-cn/web/javascript/reference/errors/missing_semicolon_before_statement/index.html
index 963008b259..434c765136 100644
--- a/files/zh-cn/web/javascript/reference/errors/missing_semicolon_before_statement/index.html
+++ b/files/zh-cn/web/javascript/reference/errors/missing_semicolon_before_statement/index.html
@@ -61,13 +61,13 @@ array[0] = "there";
 
 

如果你用的是另一种编程语言,那么在javaScript中使用不具有相同或完全没有意义的关键字也是很常见的:

-
def print(info){
+
def print(info){
   console.log(info);
 }; // SyntaxError missing ; before statement

因此,建议使用function而不是def

-
function print(info){
+
function print(info){
   console.log(info);
 };
diff --git a/files/zh-cn/web/javascript/reference/errors/not_defined/index.html b/files/zh-cn/web/javascript/reference/errors/not_defined/index.html index cc5fadb2a8..070e804d5c 100644 --- a/files/zh-cn/web/javascript/reference/errors/not_defined/index.html +++ b/files/zh-cn/web/javascript/reference/errors/not_defined/index.html @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Errors/Not_defined

在某些地方引用一个不存在的变量的时候。当你使用变量的时候,这个变量必须是已经被声明的,或者你可以确保它在你当前的脚本或作用域 ({{Glossary("scope")}}) 中可用。

-

注意: 当你加载一个库的时候(例如 jQuery),请确保你在这个库加载完毕后再使用这个库中的变量,如“$”。将你想加载的库的 {{HTMLElement("script")}} 标签放置在你的代码前面。

+

备注: 当你加载一个库的时候(例如 jQuery),请确保你在这个库加载完毕后再使用这个库中的变量,如“$”。将你想加载的库的 {{HTMLElement("script")}} 标签放置在你的代码前面。

示例

diff --git a/files/zh-cn/web/javascript/reference/functions/arguments/callee/index.html b/files/zh-cn/web/javascript/reference/functions/arguments/callee/index.html index 65e9123fe5..c448f3b091 100644 --- a/files/zh-cn/web/javascript/reference/functions/arguments/callee/index.html +++ b/files/zh-cn/web/javascript/reference/functions/arguments/callee/index.html @@ -19,7 +19,7 @@ translation_of: Web/JavaScript/Reference/Functions/arguments/callee

callee 是 arguments 对象的一个属性。它可以用于引用该函数的函数体内当前正在执行的函数。这在函数的名称是未知时很有用,例如在没有名称的函数表达式 (也称为“匿名函数”)内。

-
警告:严格模式下,第5版 ECMAScript (ES5) 禁止使用 arguments.callee()。当一个函数必须调用自身的时候, 避免使用 arguments.callee(), 通过要么给函数表达式一个名字,要么使用一个函数声明.
+

警告:严格模式下,第5版 ECMAScript (ES5) 禁止使用 arguments.callee()。当一个函数必须调用自身的时候, 避免使用 arguments.callee(), 通过要么给函数表达式一个名字,要么使用一个函数声明.

为什么 arguments.callee 从ES5严格模式中删除了?

diff --git a/files/zh-cn/web/javascript/reference/functions/arguments/index.html b/files/zh-cn/web/javascript/reference/functions/arguments/index.html index 8b708b2c37..db796d1651 100644 --- a/files/zh-cn/web/javascript/reference/functions/arguments/index.html +++ b/files/zh-cn/web/javascript/reference/functions/arguments/index.html @@ -21,12 +21,12 @@ translation_of: Web/JavaScript/Reference/Functions/arguments

描述

-
-

Note: If you're writing ES6 compatible code, then rest parameters should be preferred.

+
+

备注: If you're writing ES6 compatible code, then rest parameters should be preferred.

-
-

Note: “Array-like” means that arguments has a {{jsxref("Functions/arguments/length", "length")}} property and properties indexed from zero, but it doesn't have {{JSxRef("Array")}}'s built-in methods like {{jsxref("Array.forEach", "forEach()")}} and {{jsxref("Array.map", "map()")}}. See §Description for details.

+
+

备注: “Array-like” means that arguments has a {{jsxref("Functions/arguments/length", "length")}} property and properties indexed from zero, but it doesn't have {{JSxRef("Array")}}'s built-in methods like {{jsxref("Array.forEach", "forEach()")}} and {{jsxref("Array.map", "map()")}}. See §Description for details.

arguments对象是所有(非箭头)函数中都可用的局部变量。你可以使用arguments对象在函数中引用函数的参数。此对象包含传递给函数的每个参数,第一个参数在索引0处。例如,如果一个函数传递了三个参数,你可以以如下方式引用他们:

@@ -51,7 +51,7 @@ const args = [...arguments];
-

对参数使用slice会阻止某些JavaScript引擎中的优化 (比如 V8 - 更多信息)。如果你关心性能,尝试通过遍历arguments对象来构造一个新的数组。另一种方法是使用被忽视的Array构造函数作为一个函数:

+

警告:对参数使用slice会阻止某些JavaScript引擎中的优化 (比如 V8 - 更多信息)。如果你关心性能,尝试通过遍历arguments对象来构造一个新的数组。另一种方法是使用被忽视的Array构造函数作为一个函数:

var args = (arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments));
 
@@ -93,20 +93,14 @@ var args = [...arguments];
arguments.callee
指向参数所属的当前执行的函数。
-
-
-
-

指向调用当前函数的函数。

-
arguments.length
传递给函数的参数数量。
arguments[@@iterator]
返回一个新的{{jsxref("Array/@@iterator", "Array 迭代器", "", 0)}} 对象,该对象包含参数中每个索引的值。
-
-
-

注意: 在严格模式下,arguments对象已与过往不同。arguments[@@iterator]不再与函数的实际形参之间共享,同时caller属性也被移除。

+
+

备注:在严格模式下,arguments对象已与过往不同。arguments[@@iterator]不再与函数的实际形参之间共享,同时caller属性也被移除。

例子

@@ -149,7 +143,7 @@ myConcat(". ", "sage", "basil", "oregano", "pepper", "parsley");

这个例子定义了一个函数通过一个字符串来创建HTML列表。这个函数唯一正式声明了的参数是一个字符。当该参数为 "u" 时,创建一个无序列表 (项目列表);当该参数为 "o" 时,则创建一个有序列表 (编号列表)。该函数定义如下:

-
function list(type) {
+
function list(type) {
   var result = "<" + type + "l><li>";
   var args = Array.prototype.slice.call(arguments, 1);
   result += args.join("</li><li>");
@@ -160,7 +154,7 @@ myConcat(". ", "sage", "basil", "oregano", "pepper", "parsley");

你可以传递任意数量的参数到该函数,并将每个参数作为一个项添加到指定类型的列表中。例如:

-
var listHTML = list("u", "One", "Two", "Three");
+
var listHTML = list("u", "One", "Two", "Three");
 
 /* listHTML is:
 
@@ -257,7 +251,7 @@ func(); // undefined
 
 

浏览器兼容

-

{{Compat("javascript.functions.arguments")}}

+{{Compat}}

相关链接

diff --git a/files/zh-cn/web/javascript/reference/functions/arrow_functions/index.html b/files/zh-cn/web/javascript/reference/functions/arrow_functions/index.html index ff24c56152..09c9864d26 100644 --- a/files/zh-cn/web/javascript/reference/functions/arrow_functions/index.html +++ b/files/zh-cn/web/javascript/reference/functions/arrow_functions/index.html @@ -22,7 +22,7 @@ translation_of: Web/JavaScript/Reference/Functions/Arrow_functions

语法

-

基础语法

+

基础语法

(param1, param2, …, paramN) => { statements }
 (param1, param2, …, paramN) => expression
diff --git a/files/zh-cn/web/javascript/reference/functions/get/index.html b/files/zh-cn/web/javascript/reference/functions/get/index.html
index 613bb86276..feb8c2f37a 100644
--- a/files/zh-cn/web/javascript/reference/functions/get/index.html
+++ b/files/zh-cn/web/javascript/reference/functions/get/index.html
@@ -102,8 +102,8 @@ console.log(obj.foo); // "bar"
  • 如果被使用,它将被访问几次,并且不需要重新计算,该值将永远不会被改变,或者不应该被重新计算。
  • -
    -

    这意味着你不应该为你希望更改其值的属性使用懒 getter,因为 getter 不会重新计算该值。

    +
    +

    备注:这意味着你不应该为你希望更改其值的属性使用懒 getter,因为 getter 不会重新计算该值。

    在以下示例中,对象具有一个 getter 属性。在获取属性时,该属性将从对象中删除并重新添加,但此时将隐式显示为数据属性。最后返回得到值。

    diff --git a/files/zh-cn/web/javascript/reference/functions/index.html b/files/zh-cn/web/javascript/reference/functions/index.html index 876a0c42ee..a1b4dcd965 100644 --- a/files/zh-cn/web/javascript/reference/functions/index.html +++ b/files/zh-cn/web/javascript/reference/functions/index.html @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Functions

    调用函数时,传递给函数的值被称为函数的实参(值传递),对应位置的函数参数名叫作形参。如果实参是一个包含原始值(数字,字符串,布尔值)的变量,则就算函数在内部改变了对应形参的值,返回后,该实参变量的值也不会改变。如果实参是一个对象引用,则对应形参会和该实参指向同一个对象。假如函数在内部改变了对应形参的值,返回后,实参指向的对象的值也会改变:

    -
     /* 定义函数 myFunc */
    +
     /* 定义函数 myFunc */
      function myFunc(theObject)
      {
        //实参 mycar 和形参 theObject 指向同一个对象.
    @@ -165,7 +165,7 @@ translation_of: Web/JavaScript/Reference/Functions
     

     Function构造函数

    -

    注意: 不推荐使用 Function 构造函数创建函数,因为它需要的函数体作为字符串可能会阻止一些JS引擎优化,也会引起其他问题。

    +

    备注: 不推荐使用 Function 构造函数创建函数,因为它需要的函数体作为字符串可能会阻止一些JS引擎优化,也会引起其他问题。

    所有其他对象, {{jsxref("Function")}} 对象可以用new操作符创建:

    @@ -184,11 +184,11 @@ translation_of: Web/JavaScript/Reference/Functions

    生成器函数的构造函数

    -

    注意: GeneratorFunction 不是一个全局对象,但可以从构造函数实例取得。(详情请查阅生成器函数).

    +

    备注: GeneratorFunction 不是一个全局对象,但可以从构造函数实例取得。(详情请查阅生成器函数).

    -

    注意: 不推荐使用构造器函数的构造函数 (GeneratorFunction constructor)创建函数,因为它需要的函数体作为字符串可能会阻止一些JS引擎优化,也会引起其他问题。

    +

    备注: 不推荐使用构造器函数的构造函数 (GeneratorFunction constructor)创建函数,因为它需要的函数体作为字符串可能会阻止一些JS引擎优化,也会引起其他问题。

    所有其他对象, {{jsxref("GeneratorFunction")}} 对象可以用 new 操作符创建:

    @@ -244,7 +244,7 @@ translation_of: Web/JavaScript/Reference/Functions

    从ECMAScript 6开始, 你可以用更短的语法定义自己的方法,类似于getters和setters。详情请查阅 method definitions .

    -
     var obj = {
    +
     var obj = {
        foo() {},
        bar() {}
      };
    @@ -267,7 +267,7 @@ translation_of: Web/JavaScript/Reference/Functions
     
     

    一个匿名函数的函数表达式,被赋值给变量multiply

    -
     var multiply = function(x, y) {
    +
     var multiply = function(x, y) {
        return x * y;
      };
     
    @@ -284,7 +284,7 @@ translation_of: Web/JavaScript/Reference/Functions

    函数名和函数的变量存在着差别。函数名不能被改变,但函数的变量却能够被再分配。函数名只能在函数体内使用。倘若在函数体外使用函数名将会导致错误(如果函数之前是通过一个var语句声明的则是undefined)。例如:

    -
    var y = function x() {};
    +
    var y = function x() {};
     alert(x); // throws an error
     
    @@ -296,12 +296,12 @@ alert(x); // throws an error

    使用用 'new Function'定义的函数没有函数名。 然而,在 SpiderMonkey JavaScript引擎中,其函数的序列化形式表现的好像它拥有一个名叫"anonymous"的名称一样。比如,使用 alert(new Function()) 输出:

    -
    function anonymous() {
    +
    function anonymous() {
     }

    而实际上其函数并没有名称,anonymous 不是一个可以在函数内被访问到的变量。例如,下面的例子将会导致错误:

    -
    var foo = new Function("alert(anonymous);");
    +
    var foo = new Function("alert(anonymous);");
     foo();
     
    @@ -345,7 +345,7 @@ function foo() { // source element

    例子

    -
    // 函数声明
    +
    // 函数声明
     function foo() {}
     
     // 函数表达式
    @@ -486,9 +486,7 @@ result = padZeros(5,4);  // returns "0005"

    浏览器兼容

    - - -

    {{Compat("javascript.functions")}}

    +{{Compat}}

    参阅

    diff --git a/files/zh-cn/web/javascript/reference/functions/method_definitions/index.html b/files/zh-cn/web/javascript/reference/functions/method_definitions/index.html index ced585a822..427aaa8c79 100644 --- a/files/zh-cn/web/javascript/reference/functions/method_definitions/index.html +++ b/files/zh-cn/web/javascript/reference/functions/method_definitions/index.html @@ -61,7 +61,7 @@ translation_of: Web/JavaScript/Reference/Functions/Method_definitions };
    -

    注意:简写语法使用命名函数而不是匿名函数(如…foo: function() {}…)。命名函数可以从函数体调用(这对匿名函数是不可能的,因为没有标识符可以引用)。详细信息,请参阅{{jsxref("Operators/function","function","#Examples")}}。

    +

    备注:简写语法使用命名函数而不是匿名函数(如…foo: function() {}…)。命名函数可以从函数体调用(这对匿名函数是不可能的,因为没有标识符可以引用)。详细信息,请参阅{{jsxref("Operators/function","function","#Examples")}}。

    生成器方法

    @@ -75,7 +75,7 @@ translation_of: Web/JavaScript/Reference/Functions/Method_definitions -
    // 用有属性名的语法定义方法(ES6之前):
    +
    // 用有属性名的语法定义方法(ES6之前):
     var obj2 = {
       g: function*() {
         var index = 0;
    @@ -155,7 +155,7 @@ new obj.g; // TypeError: obj.g is not a constructor (changed in ES2016)
     
     

    简单示例

    -
    var obj = {
    +
    var obj = {
       a : "foo",
       b(){ return this.a; }
     };
    @@ -166,7 +166,7 @@ console.log(obj.b()); // "foo"
     
     

    该简写语法还支持计算的属性名称作为方法名。

    -
    var bar = {
    +
    var bar = {
       foo0: function() { return 0; },
       foo1() { return 1; },
       ['foo' + 2]() { return 2; }
    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 dbd74c0909..b612dc454f 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
    @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat
     
     
     
    -

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

    +

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

    示例

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html index 38d4388b52..ae369c0559 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/every/index.html @@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/every

    every() 方法测试一个数组内的所有元素是否都能通过某个指定函数的测试。它返回一个布尔值。

    -

    注意:若收到一个空数组,此方法在一切情况下都会返回 true

    +

    备注::若收到一个空数组,此方法在一切情况下都会返回 true

    {{EmbedInteractiveExample("pages/js/array-every.html")}}
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html index 4f06aff1fc..ec0af471c3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/flat/index.html @@ -76,7 +76,7 @@ arr.reduce((acc, val) => acc.concat(val), []); // 使用扩展运算符 ... const flattened = arr => [].concat(...arr);
    -

    reduce + concat + isArray + recursivity

    +

    reduce + concat + isArray + recursivity

    // 使用 reduce、concat 和递归展开无限多层嵌套的数组
       var arr1 = [1,2,3,[1,2,3,4, [2,3,4]]];
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/foreach/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/foreach/index.html
    index 6f93bd4513..1c9a181656 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/array/foreach/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/array/foreach/index.html
    @@ -65,7 +65,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/forEach
     

    forEach() 被调用时,不会改变原数组,也就是调用它的数组(尽管 callback 函数在被调用时可能会改变原数组)。(译注:此处说法可能不够明确,具体可参考EMCA语言规范:'forEach does not directly mutate the object on which it is called but the object may be mutated by the calls to callbackfn.',即 forEach 不会直接改变调用它的对象,但是那个对象可能会被 callback 函数改变。)

    -

    注意: 除了抛出异常以外,没有办法中止或跳出 forEach() 循环。如果你需要中止或跳出循环,forEach() 方法不是应当使用的工具。

    +

    备注: 除了抛出异常以外,没有办法中止或跳出 forEach() 循环。如果你需要中止或跳出循环,forEach() 方法不是应当使用的工具。

    若你需要提前终止循环,你可以使用:

    @@ -129,8 +129,8 @@ items.forEach(function(item){

    打印出数组的内容

    -
    -

    注意:为了在控制台中显示数组的内容,你可以使用 console.table() 来展示经过格式化的数组。下面的例子则是另一种使用 forEach() 的格式化的方法。

    +
    +

    备注:为了在控制台中显示数组的内容,你可以使用 console.table() 来展示经过格式化的数组。下面的例子则是另一种使用 forEach() 的格式化的方法。

    下面的代码会为每一个数组元素输出一行记录:

    @@ -174,7 +174,9 @@ obj.sum;

    因为 thisArg 参数(this)传给了 forEach(),每次调用时,它都被传给 callback 函数,作为它的 this 值。

    -
    注意:如果使用箭头函数表达式来传入函数参数, thisArg 参数会被忽略,因为箭头函数在词法上绑定了 {{jsxref("Operators/this", "this")}} 值。
    +
    +

    备注:如果使用箭头函数表达式来传入函数参数, thisArg 参数会被忽略,因为箭头函数在词法上绑定了 {{jsxref("Operators/this", "this")}} 值。

    +

    对象复制器函数

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/includes/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/includes/index.html index 5001b155be..3fdd124719 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/includes/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/array/includes/index.html @@ -28,8 +28,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/includes

    需要查找的元素值。

    -
    -

    Note: 使用 includes()比较字符串和字符时是区分大小写的。

    +
    +

    备注:使用 includes()比较字符串和字符时是区分大小写的。

    fromIndex {{optional_inline}}
    @@ -43,7 +43,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/includes

    0 的值将全部视为相等,与符号无关(即 -0 与 0 和 +0 相等),但 false 不被认为与 0 相等。

    -

    Note: 技术上来讲,includes() 使用 零值相等 算法来确定是否找到给定的元素。

    +

    备注: 技术上来讲,includes() 使用 零值相等 算法来确定是否找到给定的元素。

    示例

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/index.md b/files/zh-cn/web/javascript/reference/global_objects/array/index.md index 70b70221e2..fa360b4d50 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/array/index.md +++ b/files/zh-cn/web/javascript/reference/global_objects/array/index.md @@ -232,9 +232,9 @@ const myArray = myRe.exec('cdbBdbsbz') - 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 a4ef7ead3b..3e24bae2c5 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 @@ -17,7 +17,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/indexOf
    {{EmbedInteractiveExample("pages/js/array-indexof.html")}}
    -

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

    +

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

    语法

    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 b4c06b6acb..defbf9c200 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 @@ -23,18 +23,18 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/join
    separator {{optional_inline}}
    指定一个字符串来分隔数组的每个元素。如果需要,将分隔符转换为字符串。如果缺省该值,数组元素用逗号(,)分隔。如果separator是空字符串(""),则所有元素之间都没有任何字符。
    -
    -

    返回值

    -
    -
    一个所有数组元素连接的字符串。如果 arr.length 为0,则返回空字符串。
    +

    返回值

    + +

    一个所有数组元素连接的字符串。如果 arr.length 为0,则返回空字符串。

    +

    描述

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

    -
    -

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

    +
    +

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

    示例

    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 1ee4198226..6731fc1d14 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 @@ -82,7 +82,7 @@ function printEntries(arr) {

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

    -
    var numbers = [1, 2, 3, 4, 5];
    +
    var numbers = [1, 2, 3, 4, 5];
     var length = numbers.length;
     for (var i = 0; i < length; i++) {
       numbers[i] *= 2;
    @@ -93,7 +93,7 @@ for (var i = 0; i < length; i++) {
     
     

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

    -
    var numbers = [1, 2, 3, 4, 5];
    +
    var numbers = [1, 2, 3, 4, 5];
     
     if (numbers.length > 3) {
       numbers.length = 3;
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html
    index d52d65e268..348d717a0f 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/array/reduce/index.html
    @@ -74,7 +74,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/Reduce
     

    回调函数第一次执行时,accumulatorcurrentValue的取值有两种情况:如果调用reduce()时提供了initialValueaccumulator取值为initialValuecurrentValue取数组中的第一个值;如果没有提供 initialValue,那么accumulator取数组中的第一个值,currentValue取数组中的第二个值。

    -

    注意:如果没有提供initialValue,reduce 会从索引1的地方开始执行 callback 方法,跳过第一个索引。如果提供initialValue,从索引0开始。

    +

    备注:如果没有提供initialValue,reduce 会从索引1的地方开始执行 callback 方法,跳过第一个索引。如果提供initialValue,从索引0开始。

    如果数组为空且没有提供initialValue,会抛出{{jsxref("TypeError")}} 。如果数组仅有一个元素(无论位置如何)并且没有提供initialValue, 或者有提供initialValue但是数组为空,那么此唯一值将被返回并且callback不会被执行。

    @@ -450,8 +450,8 @@ var allbooks = friends.reduce(function(prev, curr) {

    数组去重

    -
    -

    注意: 如果你正在使用一个可以兼容{{jsxref("Set")}} 和 {{jsxref("Array.from()")}} 的环境, 你可以使用let orderedArray = Array.from(new Set(myArray)); 来获得一个相同元素被移除的数组。

    +
    +

    备注: 如果你正在使用一个可以兼容{{jsxref("Set")}} 和 {{jsxref("Array.from()")}} 的环境, 你可以使用let orderedArray = Array.from(new Set(myArray)); 来获得一个相同元素被移除的数组。

    let myArray = ['a', 'b', 'a', 'b', 'c', 'e', 'e', 'c', 'd', 'd', 'd', 'd']
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html
    index 793a4fd3a3..8517f6e749 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/array/reduceright/index.html
    @@ -27,28 +27,26 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/ReduceRight
     
    callback
    一个回调函数,用于操作数组中的每个元素,它可接受四个参数: -
    -
    accumulator
    -
    累加器:上一次调用回调函数时,回调函数返回的值。首次调用回调函数时,如果 initialValue 存在,累加器即为 initialValue,否则须为数组中的最后一个元素(详见下方 initialValue 处相关说明)。
    -
    currentValue
    -
    当前元素:当前被处理的元素。
    -
    index{{optional_inline}}
    -
    数组中当前被处理的元素的索引。
    -
    array{{optional_inline}}
    -
    调用 reduceRight() 的数组。
    -
    +
    +
    accumulator
    +
    累加器:上一次调用回调函数时,回调函数返回的值。首次调用回调函数时,如果 initialValue 存在,累加器即为 initialValue,否则须为数组中的最后一个元素(详见下方 initialValue 处相关说明)。
    +
    currentValue
    +
    当前元素:当前被处理的元素。
    +
    index{{optional_inline}}
    +
    数组中当前被处理的元素的索引。
    +
    array{{optional_inline}}
    +
    调用 reduceRight() 的数组。
    +
    initialValue{{optional_inline}} 
    首次调用 callback 函数时,累加器 accumulator 的值。如果未提供该初始值,则将使用数组中的最后一个元素,并跳过该元素。如果不给出初始值,则需保证数组不为空。
    否则,在空数组上调用 reducereduceRight 且未提供初始值(例如 [].reduce( (acc, cur, idx, arr) => {} ) )的话,会导致类型错误 TypeError: reduce of empty array with no initial value
    -
    -

    返回值

    -
    -
    -

    执行之后的返回值。

    -
    +

    返回值

    + +

    执行之后的返回值。

    +

    描述

    reduceRight 为数组中每个元素调用一次 callback 回调函数,但是数组中被删除的索引或从未被赋值的索引会跳过。回调函数接受四个参数:初始值(或上次调用回调的返回值)、当前元素值、当前索引,以及调用迭代的当前数组。

    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 b20d27f664..2d44c8dc8d 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 @@ -58,8 +58,8 @@ var citrus = fruits.slice(1, 3); // citrus contains ['Orange','Lemon']
    -
    -

    译者注:citrus [n.] 柑橘类果实

    +
    +

    标注: citrus [n.] 柑橘类果实——译注

    使用 slice

    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 a0f5695dfb..7d5102b182 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 @@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some

    some() 方法测试数组中是不是至少有1个元素通过了被提供的函数测试。它返回的是一个Boolean类型的值。

    -

    注意:如果用一个空数组进行测试,在任何情况下它返回的都是false

    +

    备注:如果用一个空数组进行测试,在任何情况下它返回的都是false

    {{EmbedInteractiveExample("pages/js/array-some.html")}}
    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 49a4339d87..51bb55254e 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 @@ -100,7 +100,7 @@ console.log(numbers);

    对象可以按照某个属性排序:

    -
    var items = [
    +
    var items = [
       { name: 'Edward', value: 21 },
       { name: 'Sharpe', value: 37 },
       { name: 'And', value: 45 },
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html b/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html
    index 92e3920d88..cbfc745614 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/array/values/index.html
    @@ -53,8 +53,8 @@ iterator.next();               // Object { value: "e", done: false }
     iterator.next();               // Object { value: undefined, done: true }
     iterator.next().value;         // undefined
    -
    -

    一次性:数组迭代器是一次性的,或者说临时对象

    +
    +

    警告:一次性:数组迭代器是一次性的,或者说临时对象

    例子:

    @@ -80,8 +80,8 @@ arr[1] = 'n'; iterator.next().value; // "n"
    -
    -

    如果数组中元素改变,那么迭代器的值也会改变

    +
    +

    备注:如果数组中元素改变,那么迭代器的值也会改变

    规范

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/asyncfunction/index.html b/files/zh-cn/web/javascript/reference/global_objects/asyncfunction/index.html index da8987cdfd..58e175eb9b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/asyncfunction/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/asyncfunction/index.html @@ -39,7 +39,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/AsyncFunction

    传递给 AsyncFunction 构造函数的所有参数,都会成为新函数中的变量,变量的名称和定义顺序与各参数相同。 

    -

    注意:使用 AsyncFunction 构造函数创建的{{jsxref("Statements/async_function", "异步函数")}} 并不会在当前上下文中创建闭包,其作用域始终是全局的。因此运行的时候只能访问它们自己的本地变量和全局变量,但不能访问构造函数被调用的那个作用域中的变量。这是它与 {{jsxref("Global_Objects/eval", "eval")}} 不同的地方。

    +

    备注: AsyncFunction 构造函数创建的{{jsxref("Statements/async_function", "异步函数")}} 并不会在当前上下文中创建闭包,其作用域始终是全局的。因此运行的时候只能访问它们自己的本地变量和全局变量,但不能访问构造函数被调用的那个作用域中的变量。这是它与 {{jsxref("Global_Objects/eval", "eval")}} 不同的地方。

    调用 AsyncFunction 构造函数时可以省略 new,其效果是一样的。

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/atomics/notify/index.html b/files/zh-cn/web/javascript/reference/global_objects/atomics/notify/index.html index 6459625463..7682af0a7b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/atomics/notify/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/atomics/notify/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Atomics/notify

    静态方法 Atomics.notify() 提醒一些在等待队列中休眠的代理。

    -

    注意:本操作仅在共享的 {{jsxref("Int32Array")}} 下可用。

    +

    备注:本操作仅在共享的 {{jsxref("Int32Array")}} 下可用。

    语法

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/atomics/wait/index.html b/files/zh-cn/web/javascript/reference/global_objects/atomics/wait/index.html index 14696990a1..ab56ef2512 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/atomics/wait/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/atomics/wait/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Atomics/wait

    静态方法 Atomics.wait() 确保了一个在 {{jsxref("Int32Array")}} 数组中给定位置的值没有发生变化、仍然是给定的值时进程将会睡眠,直到被唤醒或超时。该方法返回一个字符串,值为"ok", "not-equal", 或 "timed-out" 之一。

    -

    注意: 这项操作仅允许同一个共享内存的 {{jsxref("Int32Array")}} 配合使用并且无法运行在主线程中。

    +

    备注:这项操作仅允许同一个共享内存的 {{jsxref("Int32Array")}} 配合使用并且无法运行在主线程中。

    语法

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/bigint/bigint/index.html b/files/zh-cn/web/javascript/reference/global_objects/bigint/bigint/index.html index 7e7a2923f6..cec0e705b2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/bigint/bigint/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/bigint/bigint/index.html @@ -19,8 +19,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/BigInt/BigInt
    被创建的对象的数值。 可以是字符串或整数。
    -
    -

    Note: BigInt() 不与 {{JSxRef("Operators/new", "new")}} 运算符一起使用。

    +
    +

    备注:: BigInt() 不与 {{JSxRef("Operators/new", "new")}} 运算符一起使用。

    例子

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/bigint/index.html b/files/zh-cn/web/javascript/reference/global_objects/bigint/index.html index 9e52874364..1ac067ad98 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/bigint/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/bigint/index.html @@ -72,8 +72,8 @@ bigN * -1n

    / 操作符对于整数的运算也没问题。可是因为这些变量是 BigInt 而不是 BigDecimal ,该操作符结果会向零取整,也就是说不会返回小数部分。

    -
    -

    当使用 BigInt 时,带小数的运算会被取整。

    +
    +

    警告:当使用 BigInt 时,带小数的运算会被取整。

    const expected = 4n / 2n;
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/bigint64array/index.html b/files/zh-cn/web/javascript/reference/global_objects/bigint64array/index.html
    index c056ac16eb..48f1d2adfc 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/bigint64array/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/bigint64array/index.html
    @@ -13,22 +13,17 @@ translation_of: Web/JavaScript/Reference/Global_Objects/BigInt64Array
     
     

    BigInt64Array()

    -

         添加一个新的BigInt64Array对象。

    +

    添加一个新的BigInt64Array对象。

    静态属性

    {{jsxref("TypedArray.BYTES_PER_ELEMENT", "BigInt64Array.BYTES_PER_ELEMENT")}}
    -
    - -

       返回一个元素大小的数字值,BigInt64Array返回 8

    - -
    +
    返回一个元素大小的数字值,BigInt64Array返回 8
    {{jsxref("TypedArray.name", "BigInt64Array.name")}}
    +
    返回构造函数名字的字符串值,如果是BigInt64Array 的话,就是"BigInt64Array".
    -

       返回构造函数名字的字符串值,如果是BigInt64Array 的话,就是"BigInt64Array".

    -

    实例属性

    @@ -39,8 +34,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/BigInt64Array
    {{jsxref("TypedArray.prototype.byteOffset", "BigInt64Array.prototype.byteOffset")}}
    返回 BigInt64Array 从{jsxref(“ArrayBuffer”)}}开始的偏移量(以字节为单位)。这在构造时已被固定的,因此是只读。
    {{jsxref("TypedArray.prototype.length", "BigInt64Array.prototype.length")}}
    -
                     -

    返回 BigInt64Array 中被 保留的元 素个数。这  在构造时是固定的,因此是只读 。  

    +
    +

    返回 BigInt64Array 中被保留的元素个数。这在构造时是固定的,因此是只读。

    @@ -54,13 +49,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/BigInt64Array
    {{jsxref("TypedArray.every", "BigInt64Array.prototype.every()")}}
    测试数组中的所有元素是否通过函数提供的测试。另请参见{jsxref(“Array.prototype.every()")}}.
    {{jsxref("TypedArray.fill", "BigInt64Array.prototype.fill()")}}
    -
    -
    -
    -
    用静态值填充从起始索引到结束索引的数组的所有元素。另请参见{jsxref(“Array.prototype.fill()")}}
    -
    -
    -
    +
    用静态值填充从起始索引到结束索引的数组的所有元素。另请参见{jsxref(“Array.prototype.fill()")}}
    {{jsxref("TypedArray.filter", "BigInt64Array.prototype.filter()")}}
    使用提供的筛选函数为其返回true的数组的所有元素创建一个新数组。另请参见{jsxref(“Array.prototype.filter()")}}
    {{jsxref("TypedArray.find", "BigInt64Array.prototype.find()")}}
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/boolean/index.html b/files/zh-cn/web/javascript/reference/global_objects/boolean/index.html index 4101843056..51e5f1bef8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/boolean/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/boolean/index.html @@ -50,8 +50,8 @@ var s = new Boolean(myString); // true

    最后,不要在应该使用基本类型布尔值的地方使用 Boolean 对象。

    -
    -

    注意:当将非标准属性document.all用作此构造函数的参数时,结果是值为false的布尔对象。 此属性是旧属性,是非标准属性,不应使用。

    +
    +

    备注:当将非标准属性document.all用作此构造函数的参数时,结果是值为false的布尔对象。 此属性是旧属性,是非标准属性,不应使用。

    构造器

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/getfloat32/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/getfloat32/index.html index b43d4df38c..8d6ac933cf 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/dataview/getfloat32/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/getfloat32/index.html @@ -29,9 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getFloat32

    返回

    -
    -
    一个带符号的32位浮点数。
    -
    +

    一个带符号的32位浮点数。

    抛出错误

    @@ -42,9 +40,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getFloat32

    说明

    -
    -
    没有对齐约束; 多字节值可以从任何偏移处获取。
    -
    +

    没有对齐约束; 多字节值可以从任何偏移处获取。

    例子

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/getfloat64/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/getfloat64/index.html index 885acb9421..f6e9ec4c7d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/dataview/getfloat64/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/getfloat64/index.html @@ -26,9 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getFloat64

    返回

    -
    -
    一个双精度浮点型64位数.
    -
    +

    一个双精度浮点型64位数.

    抛出错误

    @@ -39,9 +37,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getFloat64

    描述

    -
    -
    没有对齐约束; 多字节值可以从任何偏移量获取.
    -
    +

    没有对齐约束; 多字节值可以从任何偏移量获取.

    例子

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/getint16/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/getint16/index.html index 060f88b722..eefe63841f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/dataview/getint16/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/getint16/index.html @@ -29,9 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getInt16

    返回

    -
    -
    一个短整型16位数.
    -
    +

    一个短整型16位数.

    抛出错误

    @@ -42,9 +40,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getInt16

    描述

    -
    -
     没有对齐约束; 多字节值可以从任何偏移量获取.
    -
    +

     没有对齐约束; 多字节值可以从任何偏移量获取.

    例子

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/getint32/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/getint32/index.html index 616d2b1977..d9bb1e5136 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/dataview/getint32/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/getint32/index.html @@ -26,9 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getInt32

    返回

    -
    -
    一个长整型32位数.
    -
    +

    一个长整型32位数.

    抛出错误

    @@ -39,9 +37,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getInt32

    描述

    -
    -
     没有对齐约束; 多字节值可以从任何偏移量获取.
    -
    +

     没有对齐约束; 多字节值可以从任何偏移量获取.

    例子

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/getint8/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/getint8/index.html index 0a8a5da6a2..2de057b837 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/dataview/getint8/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/getint8/index.html @@ -34,9 +34,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getInt8

    描述

    -
    -
     没有对齐约束; 多字节值可以从任何偏移量获取.
    -
    +

     没有对齐约束; 多字节值可以从任何偏移量获取.

    例子

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint16/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint16/index.html index 6ed5b252da..3b7d2e5c56 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint16/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint16/index.html @@ -29,9 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getUint16

    返回

    -
    -
    一个无符号短整型16位数.
    -
    +

    一个无符号短整型16位数.

    抛出错误

    @@ -42,9 +40,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getUint16

    描述

    -
    -
    没有对齐约束; 多字节值可以从任何偏移量获取.
    -
    +

    没有对齐约束; 多字节值可以从任何偏移量获取.

    例子

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint32/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint32/index.html index 3affb0312a..8287ff8463 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint32/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint32/index.html @@ -26,9 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getUint32

    返回

    -
    -
    一个无符号长整型32位数.
    -
    +

    一个无符号长整型32位数.

    抛出错误

    @@ -39,9 +37,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getUint32

    描述

    -
    -
    没有对齐约束; 多字节值可以从任何偏移量获取.
    -
    +

    没有对齐约束; 多字节值可以从任何偏移量获取.

    例子

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint8/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint8/index.html index 4e26ade311..0d12718d1c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint8/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/getuint8/index.html @@ -34,9 +34,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/getUint8

    描述

    -
    -
     没有对齐约束; 多字节值可以从任何偏移量获取.
    -
    +

     没有对齐约束; 多字节值可以从任何偏移量获取.

    例子

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/dataview/setint8/index.html b/files/zh-cn/web/javascript/reference/global_objects/dataview/setint8/index.html index dc7c7b30e4..7938a2183a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/dataview/setint8/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/dataview/setint8/index.html @@ -22,13 +22,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/DataView/setInt8
    偏移量,从头开始计算,单位为字节
    value
    设置的整数值
    -
    -

    返回

    - -

    {{jsxref("undefined")}}.

    -
    +

    返回

    + +

    {{jsxref("undefined")}}.

    +

    抛出的错误

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/date/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/date/index.html index f97d377482..bc5f87a4aa 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/date/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/date/index.html @@ -19,8 +19,8 @@ new Date(dateString) new Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]])
    -
    -

    Note: The only correct way to instantiate a new Date object is by using the {{jsxref("new")}} operator. If you simply call the Date object directly, such as now = Date(), the returned value is a string rather than a Date object.

    +
    +

    备注: The only correct way to instantiate a new Date object is by using the {{jsxref("new")}} operator. If you simply call the Date object directly, such as now = Date(), the returned value is a string rather than a Date object.

    Parameters

    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 7e7e429c3d..0e86ba5d6e 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 @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDate

    语法

    -
    dateObj.getDate()
    +
    dateObj.getDate()

    参数

    @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDate

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

    -
    var Xmas95 = new Date("December 25, 1995 23:15:00");
    +
    var Xmas95 = new Date("December 25, 1995 23:15:00");
     var day = Xmas95.getDate();
     
     alert(day); // 25
    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 cc3a17b6c4..e299df4666 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 @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDay

    语法

    -
    dateObj.getDay()
    +
    dateObj.getDay()
     

    返回值

    @@ -26,13 +26,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getDay

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

    -
    var Xmas95 = new Date("December 25, 1995 23:15:30");
    +
    var Xmas95 = new Date("December 25, 1995 23:15:30");
     var weekday = Xmas95.getDay();
     
     console.log(weekday); // 1
    -
    -

    注意:如果需要,可以使用{{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}}与一个额外的options 参数,从而返回这天的全称(如"Monday").使用此方法,结果会更加国际化:

    +
    +

    备注:如果需要,可以使用{{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}}与一个额外的options 参数,从而返回这天的全称(如"Monday").使用此方法,结果会更加国际化:

    var options = { weekday: 'long'};
     console.log(new Intl.DateTimeFormat('en-US', options).format(Xmas95));
    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 2046e96d75..abd1ea2fd4 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
    @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getHours
     
     

    语法

    -
    dateObj.getHours()
    +
    dateObj.getHours()

    参数

    @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getHours

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

    -
    var Xmas95 = new Date("December 25, 1995 23:15:00");
    +
    var Xmas95 = new Date("December 25, 1995 23:15:00");
     var hours = Xmas95.getHours();
     
     alert(hours); // 23
    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 231cf2d7f9..40b3ac6eb5 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 @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds

    语法

    -
    dateObj.getMilliseconds()
    +
    dateObj.getMilliseconds()

    参数

    @@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds

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

    -
    var ms;
    +
    var ms;
     Today = new Date();
     ms = Today.getMilliseconds();
    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 27adb1a179..7ebdff046e 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 @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMinutes

    语法

    -
    dateObj.getMinutes()
    +
    dateObj.getMinutes()

    参数

    @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMinutes

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

    -
    var Xmas95 = new Date("December 25, 1995 23:15:00");
    +
    var Xmas95 = new Date("December 25, 1995 23:15:00");
     var minutes = Xmas95.getMinutes();

    规范

    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 ce008a4ba0..f4baba5270 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 @@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMonth

    语法

    -
    dateObj.getMonth()
    +
    dateObj.getMonth()

    参数

    @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getMonth

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

    -
    var Xmas95 = new Date('December 25, 1995 23:15:30');
    +
    var Xmas95 = new Date('December 25, 1995 23:15:30');
     var month = Xmas95.getMonth();
     
     console.log(month); // 11
    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 4543e5c2b2..dbd4590d22 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 @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getSeconds

    语法

    -
    dateObj.getSeconds()
    +
    dateObj.getSeconds()

    参数

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

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

    -
    var Xmas95 = new Date("December 25, 1995 23:15:30");
    +
    var Xmas95 = new Date("December 25, 1995 23:15:30");
     var secs = Xmas95.getSeconds();
    -
     
    - -
     
    -

    规范

    属性/元素 - 说明 - 示例 + 属性/元素 + 说明 + 示例
    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 7f2d81f94e..f85174cd35 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 @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset

    语法

    -
    dateObj.getTimezoneOffset()
    +
    dateObj.getTimezoneOffset()

    参数

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/index.html index d7dd9f80b5..19b33d4de4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/index.html @@ -24,7 +24,7 @@ new Date(dateString); new Date(year, monthIndex [, day [, hours [, minutes [, seconds [, milliseconds]]]]]);
    -

    创建一个新Date对象的唯一方法是通过{{jsxref("Operators/new", "new")}} 操作符,例如:let now = new Date();
    +

    备注:创建一个新Date对象的唯一方法是通过{{jsxref("Operators/new", "new")}} 操作符,例如:let now = new Date();
    若将它作为常规函数调用(即不加 {{jsxref("Operators/new", "new")}} 操作符),将返回一个字符串,而非 Date 对象。 

    @@ -41,10 +41,10 @@ new Date(year, monthIndex [, day [, hours<
    value
    一个 Unix 时间戳(Unix Time Stamp),它是一个整数值,表示自1970年1月1日00:00:00 UTC(the Unix epoch)以来的毫秒数,忽略了闰秒。请注意大多数 Unix 时间戳功能仅精确到最接近的秒。
    -

    时间戳字符串

    dateString
    +
    时间戳字符串 dateString
    表示日期的字符串值。该字符串应该能被 {{jsxref("Date.parse()")}} 正确方法识别(即符合 IETF-compliant RFC 2822 timestamps 或 version of ISO8601)。
    -

    注意: 由于浏览器之间的差异与不一致性,强烈不推荐使用Date构造函数来解析日期字符串 (或使用与其等价的Date.parse)。对 RFC 2822 格式的日期仅有约定俗成的支持。 对 ISO 8601 格式的支持中,仅有日期的串 (例如 "1970-01-01") 会被处理为 UTC 而不是本地时间,与其他格式的串的处理不同。

    +

    备注:由于浏览器之间的差异与不一致性,强烈不推荐使用Date构造函数来解析日期字符串 (或使用与其等价的Date.parse)。对 RFC 2822 格式的日期仅有约定俗成的支持。 对 ISO 8601 格式的支持中,仅有日期的串 (例如 "1970-01-01") 会被处理为 UTC 而不是本地时间,与其他格式的串的处理不同。

    @@ -73,15 +73,15 @@ new Date(year, monthIndex [, day [, hours<

    使用注释

    -

    注意 参数monthIndex 是从“0”开始计算的,这就意味着一月份为“0”,十二月份为“11”。

    +

    备注:参数monthIndex 是从“0”开始计算的,这就意味着一月份为“0”,十二月份为“11”。

    -

    注意:当Date作为构造函数调用并传入多个参数时,如果数值大于合理范围时(如月份为 13 或者分钟数为 70),相邻的数值会被调整。比如 new Date(2013, 13, 1)等于new Date(2014, 1, 1),它们都表示日期2014-02-01(注意月份是从0开始的)。其他数值也是类似,new Date(2013, 2, 1, 0, 70)等于new Date(2013, 2, 1, 1, 10),都表示同一个时间:2013-03-01T01:10:00

    +

    备注:当Date作为构造函数调用并传入多个参数时,如果数值大于合理范围时(如月份为 13 或者分钟数为 70),相邻的数值会被调整。比如 new Date(2013, 13, 1)等于new Date(2014, 1, 1),它们都表示日期2014-02-01(注意月份是从0开始的)。其他数值也是类似,new Date(2013, 2, 1, 0, 70)等于new Date(2013, 2, 1, 1, 10),都表示同一个时间:2013-03-01T01:10:00

    -

    注意:当Date作为构造函数调用并传入多个参数时,所定义参数代表的是当地时间。如果需要使用世界协调时 UTC,使用 new Date({{jsxref("Date.UTC()", "Date.UTC(...)")}}) 和相同参数。

    +

    备注:当Date作为构造函数调用并传入多个参数时,所定义参数代表的是当地时间。如果需要使用世界协调时 UTC,使用 new Date({{jsxref("Date.UTC()", "Date.UTC(...)")}}) 和相同参数。

    简介

    @@ -112,7 +112,7 @@ new Date(year, monthIndex [, day [, hours<
    {{jsxref("Date.parse()")}}
    解析一个表示日期的字符串,并返回从 1970-1-1 00:00:00 所经过的毫秒数。
    -

    注意: 由于浏览器差异和不一致,强烈建议不要使用Date.parse解析字符串。

    +

    备注: 由于浏览器差异和不一致,强烈建议不要使用Date.parse解析字符串。

    {{jsxref("Date.UTC()")}}
    @@ -141,7 +141,7 @@ new Date(year, monthIndex [, day [, hours<

    下例展示了用来创建一个日期对象的多种方法。

    -

    注意: 由于浏览器差异和不一致性,强烈建议不要使用Date构造函数(和Date.parse,它们是等效的)解析日期字符串。

    +

    备注: 由于浏览器差异和不一致性,强烈建议不要使用Date构造函数(和Date.parse,它们是等效的)解析日期字符串。

    var today = new Date();
    @@ -197,7 +197,7 @@ yourFunctionReturn = printElapsedTime(yourFunction);
     
    -

    注意:在支持 {{domxref("window.performance", "Web Performance API")}} 的高精细度(high-resolution)时间功能的浏览器中,{{domxref("Performance.now()")}} 提供的所经过的时间比 {{jsxref("Date.now()")}} 更加可靠、精确。

    +

    备注:在支持 {{domxref("window.performance", "Web Performance API")}} 的高精细度(high-resolution)时间功能的浏览器中,{{domxref("Performance.now()")}} 提供的所经过的时间比 {{jsxref("Date.now()")}} 更加可靠、精确。

    获取自 Unix 起始时间以来经过的秒数

    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 eef2f86594..d479715f29 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 @@ -38,9 +38,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse

    返回值

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

    一个表示从1970-1-1 00:00:00 UTC到给定日期字符串所表示时间的毫秒数的数值。如果参数不能解析为一个有效的日期,则返回{{jsxref("NaN")}}。

    描述

    @@ -70,22 +68,22 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse

    但是, 在如 ECMA-262 规范中定义的情况,如果因为无效值而导致日期字符串不能被识别为 ISO 格式时,根据浏览器和给定的值不同,返回值可以是,也可以不是 {{jsxref("NaN")}} 。比如:

    -
    // 包含无效值的非 ISO 格式字符串
    +
    // 包含无效值的非 ISO 格式字符串
     new Date('23/25/2014');

    在 Firefox 30 中会被识别为本地时区的2015年12月25日,而在 Safari 7 中则是无效日期。但是,如果字符串被识别为 ISO 格式并且包含无效值,则在所有遵循 ES5 或者更新标准的浏览器中都会返回 {{jsxref("NaN")}} 。

    -
    // 包含无效值的 ISO 格式字符串
    +
    // 包含无效值的 ISO 格式字符串
     new Date('2014-25-23').toISOString();
     // 在所有遵循 ES5的浏览器中返回 "RangeError: invalid date"

    SpiderMonkey 的引擎策略可以在 jsdate.cpp  中找到。字符串 "10 06 2014"  可以作为非 ISO 格式字符串使用自定义处理方式的例子。参见这篇关于解析如何进行的粗略纲要

    -
    new Date('10 06 2014');
    +
    new Date('10 06 2014');

    将会被解析为本地时间 2014年10月6日,而不是6月10日。另一个例子

    -
    new Date('foo-bar 2014').toString();
    +
    new Date('foo-bar 2014').toString();
     // 返回: "Invalid Date"
     
     Date.parse('foo-bar 2014');
    @@ -97,7 +95,7 @@ Date.parse('foo-bar 2014');
     
     

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

    -
    IPOdate.setTime(Date.parse('Aug 9, 1995'));
    +
    IPOdate.setTime(Date.parse('Aug 9, 1995'));

    其他一些解析非标准格式日期的例子:

    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 5c85e43084..b2393680ba 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 @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setFullYear

    语法

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

    参数

    @@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setFullYear

    例子:使用setFullYear方法

    -
    var theBigDay = new Date();
    +
    var theBigDay = new Date();
     theBigDay.setFullYear(1997);

    规范

    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 ef3ce60645..28e6aee649 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 @@ -20,12 +20,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/setTime
    timeValue
    一个整数,表示从1970-1-1 00:00:00 UTC开始计时的毫秒数。
    -
    -

    返回值

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

    返回值

    +

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

    +

    描述

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

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/decodeuricomponent/index.html b/files/zh-cn/web/javascript/reference/global_objects/decodeuricomponent/index.html index 7db77bdbf1..7857abb575 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/decodeuricomponent/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/decodeuricomponent/index.html @@ -55,87 +55,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/decodeURIComponent

    规范

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    规范状态备注
    {{SpecName('ES3')}}{{Spec2('ES3')}}初始定义
    {{SpecName('ES5.1', '#sec-15.1.3.2', 'decodeURIComponent')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-decodeuricomponent-encodeduricomponent', 'decodeURIComponent')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-decodeuricomponent-encodeduricomponent', 'decodeURIComponent')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基础功能{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    特性AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基础功能{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/encodeuri/index.html b/files/zh-cn/web/javascript/reference/global_objects/encodeuri/index.html index 1bb8380c20..1a54a66c42 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/encodeuri/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/encodeuri/index.html @@ -22,13 +22,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/encodeURI
    URI
    一个完整的URI.
    -
    -

    返回值

    - -

        一个新字符串, 表示提供的字符串编码为统一资源标识符 (URI)。

    -
    +

    返回值

    + +

        一个新字符串, 表示提供的字符串编码为统一资源标识符 (URI)。

    +

    描述

    假定一个URI是完整的URI,那么无需对那些保留的并且在URI中有特殊意思的字符进行编码。

    @@ -40,8 +39,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/encodeURI - - + + @@ -79,87 +78,11 @@ console.log(encodeURI('\uDFFF'));

    规范

    -
    类型包含类型包含
    保留字符
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    规范状态备注
    {{SpecName('ES3')}}{{Spec2('ES3')}}初始定义
    {{SpecName('ES5.1', '#sec-15.1.3.3', 'encodeURI')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-encodeuri-uri', 'encodeURI')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-encodeuri-uri', 'encodeURI')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基础功能{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    特性AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基础功能{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/columnnumber/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/columnnumber/index.html index e1e1161fbd..a39fa3b734 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/columnnumber/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/columnnumber/index.html @@ -18,59 +18,11 @@ console.log(e.columnNumber) // 0

    规范

    -

    不属于任何规范的一部分. 非标准.

    +{{Specifications}}

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支持{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基本支持{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/filename/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/filename/index.html index 2ef563d050..8e679effa2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/filename/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/filename/index.html @@ -22,59 +22,11 @@ throw e;

    规范

    -

    不属于任何规范的一部分. 非标准.

    +{{Specifications}} -

    Browser compatibility

    +

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支持{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基本支持{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关链接

    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 80da68f766..2717020571 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 @@ -121,7 +121,7 @@ const y = new Error('I was constructed via the "new" keyword!');

    你可能希望自定义基于Error的异常类型,使得你能够 throw new MyError() 并可以使用 instanceof MyError 来检查某个异常的类型. 这种需求的通用解决方法如下.

    -

    注意,在FireFox中抛出自定义类型的异常会显示不正确的行号和文件名。

    +

    警告:注意,在FireFox中抛出自定义类型的异常会显示不正确的行号和文件名。

    参考 "What's a good way to extend Error in JavaScript?" discussion on Stackoverflow.

    @@ -149,48 +149,6 @@ try { console.log(e.message); // 'custom message' }
    -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    - -
    -

    规范

    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 ff4dce9d23..7979ed0998 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 @@ -25,82 +25,11 @@ throw e;

    规范

    -
    - - - - - - - - - - - - - - - - - - - - - - -
    规范版本规范状态注解
    ECMAScript 1st Edition.StandardInitial definition.
    {{SpecName('ES5.1', '#sec-15.11.4.3', 'Error.prototype.message')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-error.prototype.message', 'Error.prototype.message')}}{{Spec2('ES6')}} 
    +{{Specifications}}

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    +{{Compat}}

    相关链接

    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 80848f54dc..e60689f3e9 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 @@ -25,82 +25,11 @@ throw e; // "ParseError: Malformed input"

    规范

    - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    ECMAScript 1st Edition.StandardInitial definition.
    {{SpecName('ES5.1', '#sec-15.11.4.2', 'Error.prototype.name')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-error.prototype.name', 'Error.prototype.name')}}{{Spec2('ES6')}} 
    +{{Specifications}}

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/error/tosource/index.html b/files/zh-cn/web/javascript/reference/global_objects/error/tosource/index.html index f6d59df24d..cc7a12d0de 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/error/tosource/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/error/tosource/index.html @@ -25,7 +25,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error/toSource

    这些属性对应于错误实例的相应属性。

    -

    提示:  需要注意到,在创建该字符串时,toSource方法所使用的属性是可变的,并且可能无法准确地反映用于创建错误实例的函数或实际发生错误的文件名或行号。

    +

    备注:  需要注意到,在创建该字符串时,toSource方法所使用的属性是可变的,并且可能无法准确地反映用于创建错误实例的函数或实际发生错误的文件名或行号。

    规范

    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 395d61aee2..2dfc20c937 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 @@ -49,80 +49,15 @@ print(e.toString()); // "Error" e.name = "hello"; print(e.toString()); // "hello"
    +

    规范

    - - - - - - - - - - - - - - - - - - - - - - - -
    规范版本规范状态注解
    ECMAScript 1st Edition.StandardInitial definition.
    - Implemented in JavaScript 1.1
    {{SpecName('ES5.1', '#sec-15.11.4.4', 'Error.prototype.toString')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-error.prototype.tostring', 'Error.prototype.toString')}}{{Spec2('ES6')}} 
    + +{{Specifications}} +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • {{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 dc558d27bd..38a2d6bea5 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 @@ -68,55 +68,7 @@ escape("@*_+-./"); // "@*_+-./"

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    +{{Compat}}

    其他链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/finalizationregistry/index.html b/files/zh-cn/web/javascript/reference/global_objects/finalizationregistry/index.html index c1823859ad..6f456c2755 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/finalizationregistry/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/finalizationregistry/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/FinalizationRegistry

    FinalizationRegistry 提供了这样的一种方法:当一个在注册表中注册的对象被回收时,请求在某个时间点上调用一个清理回调。(清理回调有时被称为 finalizer )。

    -

    注意: 清理回调不应被用于必要的程序逻辑。详情请看清理回调的注意事项

    +

    备注: 清理回调不应被用于必要的程序逻辑。详情请看清理回调的注意事项

    你在回调中创建了如下的 registry:

    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 8acfb7feee..8c78a91ccf 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 @@ -173,74 +173,9 @@ var z = new Float32Array(buffer, 0, 4); -

    浏览器兼容

    +

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基础支持7.0{{CompatGeckoDesktop(2)}}1011.65.1
    需要new{{CompatUnknown}}{{CompatGeckoDesktop(44)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    特性AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基础支持4.0{{CompatVersionUnknown}}{{CompatGeckoMobile(2)}}1011.64.2
    需要new{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(44)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    一致性提示

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/float64array/index.html b/files/zh-cn/web/javascript/reference/global_objects/float64array/index.html index 7cc7d30a39..cc879d7e7d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/float64array/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/float64array/index.html @@ -171,74 +171,9 @@ var z = new Float64Array(buffer, 0, 4); -

    浏览器兼容

    +

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基础支持7.0{{CompatGeckoDesktop(2)}}1011.65.1
    需要用new{{CompatUnknown}}{{CompatGeckoDesktop(44)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    特性AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基础支持4.0{{CompatVersionUnknown}}{{ CompatGeckoMobile(2) }}1011.64.2
    需要用new{{CompatUnknown}}{{CompatUnknown}}{{ CompatGeckoMobile(44) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    一致性提示

    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 67a69174e6..bee3572f70 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 @@ -11,7 +11,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply

    apply() 方法调用一个具有给定this值的函数,以及以一个数组(或类数组对象)的形式提供的参数。

    -
    注意:call()方法的作用和 apply() 方法类似,区别就是call()方法接受的是参数列表,而apply()方法接受的是一个参数数组
    +
    +

    备注:call()方法的作用和 apply() 方法类似,区别就是call()方法接受的是参数列表,而apply()方法接受的是一个参数数组

    +
    {{EmbedInteractiveExample("pages/js/function-apply.html")}}
    @@ -45,7 +47,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply

    从 ECMAScript 第5版开始,可以使用任何种类的类数组对象,就是说只要有一个 length 属性和(0..length-1)范围的整数属性。例如现在可以使用 {{domxref("NodeList")}} 或一个自己定义的类似 {'length': 2, '0': 'eat', '1': 'bananas'} 形式的对象。

    -

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

    +

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

    示例

    @@ -118,7 +120,7 @@ var min = minOfArray([5, 6, 2, 3, 7]);
    -

    注意: 上面使用的Object.create()方法相对来说比较新。另一种可选的方法,请考虑如下替代方法:

    +

    备注: 上面使用的Object.create()方法相对来说比较新。另一种可选的方法,请考虑如下替代方法:

    Using {{jsxref("Object/__proto__", "Object.__proto__")}}:

    @@ -166,7 +168,9 @@ console.log(myInstance instanceof MyConstructor); // logs "true" console.log(myInstance.constructor);              // logs "MyConstructor"
    -
    注意: 这个非native的Function.construct方法无法和一些native构造器(例如Date)一起使用。 在这种情况下你必须使用Function.bind方法(例如,想象有如下一个数组要用在Date构造器中: [2012, 11, 4];这时你需要这样写: new (Function.prototype.bind.apply(Date, [null].concat([2012, 11, 4])))() – -无论如何这不是最好的实现方式并且也许不该用在任何生产环境中).
    +
    +

    备注: 这个非native的Function.construct方法无法和一些native构造器(例如Date)一起使用。 在这种情况下你必须使用Function.bind方法(例如,想象有如下一个数组要用在Date构造器中: [2012, 11, 4];这时你需要这样写: new (Function.prototype.bind.apply(Date, [null].concat([2012, 11, 4])))() – -无论如何这不是最好的实现方式并且也许不该用在任何生产环境中).

    +

    规范

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/arguments/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/arguments/index.html index ef832c70db..f7ab79e806 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/arguments/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/arguments/index.html @@ -5,7 +5,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/arguments ---
    {{JSRef}} {{deprecated_header}}
    -

    function.arguments 属性代表传入函数的实参,它是一个类数组对象。

    +

    function.arguments 属性代表传入函数的实参,它是一个类数组对象。

    描述

    @@ -67,55 +67,7 @@ console.log('函数退出后的 arguments 属性值:' + g.arguments);

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/bind/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/bind/index.html index 45ee18de46..cb2c83b2a7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/bind/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/bind/index.html @@ -140,7 +140,7 @@ flower.bloom(); // 一秒钟后, 调用 'declare' 方法

    作为构造函数使用的绑定函数

    -

    警告 :这部分演示了 JavaScript 的能力并且记录了 bind() 的超前用法。以下展示的方法并不是最佳的解决方案,且可能不应该用在任何生产环境中。

    +

    警告:这部分演示了 JavaScript 的能力并且记录了 bind() 的超前用法。以下展示的方法并不是最佳的解决方案,且可能不应该用在任何生产环境中。

    绑定函数自动适应于使用 {{jsxref("Operators/new", "new")}} 操作符去构造一个由目标函数创建的新实例。当一个绑定函数是用来构建一个值的,原来提供的 this 就会被忽略。不过提供的参数列表仍然会插入到构造函数调用时的参数列表之前。

    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 9474d40416..a4bce37d0f 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 @@ -11,7 +11,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/call

    call() 方法使用一个指定的 this 值和单独给出的一个或多个参数来调用一个函数。

    -
    注意:该方法的语法和作用与 {{jsxref("Function.apply", "apply()")}} 方法类似,只有一个区别,就是 call() 方法接受的是一个参数列表,而 apply() 方法接受的是一个包含多个参数的数组
    +
    +

    备注:该方法的语法和作用与 {{jsxref("Function.apply", "apply()")}} 方法类似,只有一个区别,就是 call() 方法接受的是一个参数列表,而 apply() 方法接受的是一个包含多个参数的数组

    +
    {{EmbedInteractiveExample("pages/js/function-call.html")}}
    @@ -114,7 +116,7 @@ function display() { display.call(); // sData value is Wisen
    -

    注意:在严格模式下,this 的值将会是 undefined。见下文。

    +

    备注:在严格模式下,this 的值将会是 undefined。见下文。

    'use strict';
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/displayname/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/displayname/index.html
    index c07f677636..4fab613040 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/function/displayname/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/function/displayname/index.html
    @@ -66,56 +66,6 @@ a; // "function My Function()"

    不属于任何规范

    -

    Browser compatibility 浏览器兼容性

    - -

    如果你愿意贡献数据,请访问https://github.com/mdn/browser-compat-data并同时给我们发送推送请求。

    - -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop(13)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +

    浏览器兼容性

    + +{{Compat}} diff --git a/files/zh-cn/web/javascript/reference/global_objects/function/name/index.html b/files/zh-cn/web/javascript/reference/global_objects/function/name/index.html index 0f7695c49e..7d0557c5a4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/function/name/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/function/name/index.html @@ -10,12 +10,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/name ---
    {{JSRef("Global_Objects", "Function")}}
    -
    function.name 属性返回函数实例的名称。
    +
    function.name 属性返回函数实例的名称。

    {{js_property_attributes(0,0,1)}}

    -

    请注意,在非标准的ES2015之前的实现中,configurable属性也是false 。

    +

    备注:在非标准的ES2015之前的实现中,configurable属性也是false 。

    示例

    @@ -184,7 +184,6 @@ if (b.constructor.name === 'Foo') {

    在未压缩版本中,程序运行到真实分支并打印'foo' is an instance of 'Foo'。 而在压缩版本中,它的行为不同,并且进入else分支。如果您依赖于Function.name,就像上面的示例一样,确保您的构建管道不会更改函数名称,也不要假定函数具有特定的名称。

    -

    规范

    @@ -210,4 +209,3 @@ if (b.constructor.name === 'Foo') {

    浏览器兼容性

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

    - 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 63d7f9a169..862cf598be 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 @@ -101,61 +101,9 @@ g.next(2);
    -

    浏览器兼容性

    +

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}13{{CompatGeckoDesktop(26)}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatSafari(10)}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support5.1{{CompatVersionUnknown}}{{CompatGeckoMobile(26)}}{{CompatUnknown}}{{CompatUnknown}}10
    -
    -
    +{{Compat}}

    相关链接

    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 63afc5f965..19acc2332a 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 @@ -83,57 +83,9 @@ g.throw(new Error("Something went wrong")); // "Error caught!" -

    浏览器兼容性

    +

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop(26)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(26)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    相关链接

    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 379b31a804..d283c29e96 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 @@ -39,7 +39,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/GeneratorFunction

    传递给函数的所有参数按照它们被传递的顺序被视为要创建的函数中参数的标识符的名称。

    -

    提示:使用GeneratorFunction构造函数创建的{{jsxref("Statements/function*", "生成器函数")}}不会为其创建上下文创建闭包;它们始终在全局范围内创建。当运行它们时,它们只能访问自己的本地变量和全局变量,而不是从GeneratorFunction构造函数调用的范围的变量。这与使用{{jsxref("Global_Objects/eval", "eval")}}与生成函数表达式的代码不同。

    +

    备注:使用GeneratorFunction构造函数创建的{{jsxref("Statements/function*", "生成器函数")}}不会为其创建上下文创建闭包;它们始终在全局范围内创建。当运行它们时,它们只能访问自己的本地变量和全局变量,而不是从GeneratorFunction构造函数调用的范围的变量。这与使用{{jsxref("Global_Objects/eval", "eval")}}与生成函数表达式的代码不同。

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

    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 a0ce09c381..20836d878b 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 @@ -25,7 +25,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Infinity

    示例

    -
    console.log(Infinity          ); /* Infinity */
    +
    console.log(Infinity          ); /* Infinity */
     console.log(Infinity + 1      ); /* Infinity */
     console.log(Math.pow(10, 1000)); /* Infinity */
     console.log(Math.log(0)       ); /* -Infinity */
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/int16array/index.html b/files/zh-cn/web/javascript/reference/global_objects/int16array/index.html
    index 6cb8a365b6..743839da50 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/int16array/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/int16array/index.html
    @@ -166,74 +166,9 @@ var z = new Int16Array(buffer, 0, 4);
      
     
     
    -

    Browser compatibility

    +

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support7.0{{ CompatGeckoDesktop(2) }}1011.65.1
    new is required{{CompatUnknown}}{{ CompatGeckoDesktop(44) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support4.0{{CompatVersionUnknown}}{{ CompatGeckoMobile(2) }}1011.64.2
    new is required{{CompatUnknown}}{{CompatUnknown}}{{ CompatGeckoMobile(44) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    Compatibility notes

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/int32array/index.html b/files/zh-cn/web/javascript/reference/global_objects/int32array/index.html index 133969ba90..2bb0a2ce60 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/int32array/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/int32array/index.html @@ -170,72 +170,7 @@ var z = new Int32Array(buffer, 0, 4);

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支持7.0{{ CompatGeckoDesktop(2) }}1011.65.1
    新 的特性{{CompatUnknown}}{{ CompatGeckoDesktop(44) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基本支持4.0{{CompatVersionUnknown}}{{ CompatGeckoMobile(2) }}1011.64.2
    的特性{{CompatUnknown}}{{CompatUnknown}}{{ CompatGeckoMobile(44) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    兼容性说明

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/int8array/index.html b/files/zh-cn/web/javascript/reference/global_objects/int8array/index.html index e437d73a73..74fbce657b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/int8array/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/int8array/index.html @@ -172,72 +172,7 @@ var z = new Int8Array(buffer, 1, 4);

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    功能ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support7.0{{ CompatGeckoDesktop("2") }}1011.65.1
    new is required{{CompatUnknown}}{{ CompatGeckoDesktop("44") }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support4.0{{CompatVersionUnknown}}{{ CompatGeckoMobile("2") }}1011.64.2
    new is required{{CompatUnknown}}{{CompatUnknown}}{{ CompatGeckoMobile("44") }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    兼容性说明

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/internalerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/internalerror/index.html index fc9c4a389f..f033e4771a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/internalerror/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/internalerror/index.html @@ -65,55 +65,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/InternalError

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支持{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基本支持{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/intl/datetimeformat/index.html b/files/zh-cn/web/javascript/reference/global_objects/intl/datetimeformat/index.html index 04d383b97d..7275668035 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/intl/datetimeformat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/intl/datetimeformat/index.html @@ -23,9 +23,8 @@ Intl.DateTimeFormat.call(this[, locales[, options译者注:下面这两种扩展的使用方式是language[-scripts][-region]-u-nu-* 和 language[-scripts][-region]-u-ca-* ,例如:zh-u-nu-hanidec(表示中文十进制数字) 和 zh-u-ca-chinese(表示中国日历,比如壬辰年冬月8日) ,也可以 nu 和 ca 组合使用 比如 使用 zh-u-ca-chinese-nu-hanidec 格式化Date.now()的返回值类似于"丙申年冬月九日"

    -

    nu

    -
    +
    nu
    编号系统. 可能的值包括: "arab", "arabext", "bali", "beng", "deva", "fullwide", "gujr", "guru", "hanidec", "khmr", "knda", "laoo", "latn", "limb", "mlym", "mong", "mymr", "orya", "tamldec", "telu", "thai", "tibt".
    ca
    日历. 可能的值包括: "buddhist", "chinese", "coptic", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamicc", "iso8601", "japanese", "persian", "roc".
    @@ -79,7 +78,7 @@ Intl.DateTimeFormat.call(this[, locales[, options时区名称的展现方式.可能的值有 "short", "long".
    -

    每个日期时间组件属性的默认值都是{{jsxref("undefined")}},但是若所有的组件属性都是{{jsxref("undefined")}},那么year, month, and day 的值就都被认为是"numeric".

    +

    每个日期时间组件属性的默认值都是{{jsxref("undefined")}},但是若所有的组件属性都是{{jsxref("undefined")}},那么year, month, and day 的值就都被认为是"numeric".

    @@ -226,55 +225,7 @@ console.log(date.toLocaleString('en-US', options));

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
    Basic support{{CompatChrome("24")}}{{CompatGeckoDesktop("29")}}{{CompatIE("11")}}{{CompatOpera("15")}}{{CompatSafari("10")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatChrome("26")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatSafari("10")}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/intl/numberformat/index.html b/files/zh-cn/web/javascript/reference/global_objects/intl/numberformat/index.html index a4b2e509de..e508097567 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/intl/numberformat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/intl/numberformat/index.html @@ -51,13 +51,7 @@ Intl.NumberFormat.call(this[, locales[, options
    unit{{Experimental_inline}}
    unit 格式中使用的单位,可能的值为在 UTS #35, Part 2, Section 6 定义的核心单元标识符。已从完整列表中选择了一个单位子集以用于ECMAScript。可以将成对的简单单位与 “ -per-” 连接以组成一个复合单位。没有默认值;如果 style“unit”,必须提供unit 属性。
    unitDisplay{{Experimental_inline}}
    -
    unit 格式化中使用的单位格式化样式,默认值为“ short”。 -
      -
    • “long” (e.g., 16 litres)
    • -
    • “short“ (e.g., 16 l)
    • -
    • ”narrow“ (e.g., 16l)
    • -
    -
    +
    unit 格式化中使用的单位格式化样式,默认值为“ short”。“long” (e.g., 16 litres)、“short“ (e.g., 16 l)、”narrow“ (e.g., 16l)
    currency
    在货币格式化中使用的货币符号. 可能的值是ISO的货币代码 (the ISO 4217 currency codes,) 例如 "USD" 表示美元, "EUR" 表示欧元, 或者 "CNY"是人民币 — 更多请参考 Current currency & funds code list。没有默认值,如果 style“currency”,必须提 currency 属性.
    currencyDisplay
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/intl/pluralrules/index.html b/files/zh-cn/web/javascript/reference/global_objects/intl/pluralrules/index.html index 77f7426002..52770bcc7a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/intl/pluralrules/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/intl/pluralrules/index.html @@ -69,7 +69,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Intl/PluralRules

    例子

    -

    基本用法 +

    基本用法

    在没有指定语言环境的基本使用中,返回默认语言环境中的格式化字符串和默认选项。这有助于区分单数和复数形式,例如“dog”和“dogs”。

    @@ -101,7 +101,7 @@ new Intl.PluralRules('ar-EG').select(6); new Intl.PluralRules('ar-EG').select(18); // → 'many'
    -

    运用 +

    运用

    可以查询查询结果使用>options参数进行自定义,该参数具有一个type您可以设置的属性ordinal。这对计算序数指标很有用,例如“第一”,“第二”,“第三”,“第四”,“42”等。

    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 f033320715..d57fd1cf34 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 @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isFinite

    语法

    -
    isFinite(testValue)
    +
    isFinite(testValue)

    参数

    @@ -25,15 +25,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isFinite

    描述

    -
    -
    isFinite 是全局的方法,不与任何对象有关系。
    -
    +

    isFinite 是全局的方法,不与任何对象有关系。

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

    示例

    -
    isFinite(Infinity);  // false
    +
    isFinite(Infinity);  // false
     isFinite(NaN);       // false
     isFinite(-Infinity); // false
     
    @@ -43,24 +41,6 @@ isFinite(2e64);      // true, 在更强壮的Number.isFinite(null)中将会得
     
     isFinite("0");       // true, 在更强壮的Number.isFinite('0')中将会得到false
    -
     
    - -
     
    - -
     
    - -
     
    - -
     
    - -
     
    - -
     
    - -
     
    - -
     
    -

    规范

    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 00704c3228..0fe301862d 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 @@ -48,7 +48,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/isNaN

    一个isNaN的 polyfill 可以理解为(这个polyfill利用了NaN自身永不相等于自身这一特征 ):

    -
    var isNaN = function(value) {
    +
    var isNaN = function(value) {
         var n = Number(value);
         return n !== n;
     };
    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 e37a4fc9ee..a124d85c97 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 @@ -31,12 +31,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/JSON/stringify
    如果该参数是一个函数,则在序列化过程中,被序列化的值的每个属性都会经过该函数的转换和处理;如果该参数是一个数组,则只有包含在这个数组中的属性名才会被序列化到最终的 JSON 字符串中;如果该参数为 null 或者未提供,则对象所有的属性都会被序列化。
    space {{optional_inline}}
    指定缩进用的空白字符串,用于美化输出(pretty-print);如果参数是个数字,它代表有多少的空格;上限为10。该值若小于1,则意味着没有空格;如果该参数为字符串(当字符串长度超过10个字母,取其前10个字母),该字符串将被作为空格;如果该参数没有提供(或者为 null),将没有空格。
    -
    -

    返回值

    -
    -
    一个表示给定值的JSON字符串。
    +

    返回值

    + +

    一个表示给定值的JSON字符串。

    +

    异常

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/map/@@tostringtag/index.html b/files/zh-cn/web/javascript/reference/global_objects/map/@@tostringtag/index.html index 186603b1a3..d74a6f0cdf 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/map/@@tostringtag/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/map/@@tostringtag/index.html @@ -49,56 +49,6 @@ browser-compat: javascript.builtins.Map.@@toStringTag
    -

    浏览器兼容

    +

    浏览器兼容性

    -

    {{CompatibilityTable}} 

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatChrome(44.0) }}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
    Basic support{{ CompatNo }}{{ CompatChrome(44.0) }}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatChrome(44.0)}}
    -
    +{{Compat}} diff --git a/files/zh-cn/web/javascript/reference/global_objects/map/delete/index.html b/files/zh-cn/web/javascript/reference/global_objects/map/delete/index.html index 6bbd943f7f..d2801c08d5 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/map/delete/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/map/delete/index.html @@ -14,7 +14,7 @@ browser-compat: javascript.builtins.Map.delete ---
    {{JSRef}}
    -

     delete() 方法用于移除 Map 对象中指定的元素。

    +

    delete() 方法用于移除 Map 对象中指定的元素。

    {{EmbedInteractiveExample("pages/js/map-prototype-delete.html")}}
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/map/has/index.html b/files/zh-cn/web/javascript/reference/global_objects/map/has/index.html index 461f2e5e07..0f5989851b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/map/has/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/map/has/index.html @@ -64,55 +64,7 @@ myMap.has("baz"); // returns false

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    浏览器Chrome谷歌Firefox (Gecko)火狐Internet ExplorerOperaSafari
    兼容版本38{{CompatGeckoDesktop("13.0")}}11257.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    浏览器AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    兼容版本{{CompatNo}}38{{CompatGeckoMobile("13.0")}}{{CompatNo}}{{CompatNo}}8
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/map/index.html b/files/zh-cn/web/javascript/reference/global_objects/map/index.html index 675b0f1b1b..606848aabd 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/map/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/map/index.html @@ -52,8 +52,8 @@ browser-compat: javascript.builtins.Map

    一个 Object 有一个原型, 原型链上的键名有可能和你自己在对象上的设置的键名产生冲突。

    -
    -

    注意: 虽然 ES5 开始可以用 Object.create(null) 来创建一个没有原型的对象,但是这种用法不太常见。

    +
    +

    备注:虽然 ES5 开始可以用 Object.create(null) 来创建一个没有原型的对象,但是这种用法不太常见。

    @@ -70,8 +70,8 @@ browser-compat: javascript.builtins.Map

    一个 Object 的键是无序的

    -
    -

    注意:自ECMAScript 2015规范以来,对象确实保留了字符串和Symbol键的创建顺序; 因此,在只有字符串键的对象上进行迭代将按插入顺序产生键。

    +
    +

    备注:自ECMAScript 2015规范以来,对象确实保留了字符串和Symbol键的创建顺序; 因此,在只有字符串键的对象上进行迭代将按插入顺序产生键。

    @@ -238,8 +238,8 @@ console.log(clone.get(1)); // one console.log(original === clone); // false. 浅比较 不为同一个对象的引用
    -
    -

    重要:请记住,数据本身未被克隆。

    +
    +

    备注:请记住,数据本身未被克隆。

    Map对象间可以进行合并,但是会保持键的唯一性。

    @@ -289,7 +289,7 @@ console.log(merged.get(3)); // three

    所以,你还是可以这样做...

    -
    let wrongMap = new Map()
    +
    let wrongMap = new Map()
     wrongMap['bla'] = 'blaa'
     wrongMap['bla2'] = 'blaaa2'
     
    @@ -298,13 +298,13 @@ console.log(wrongMap)  // Map { bla: 'blaa', bla2: 'blaaa2' }
     
     

    ...但是,这样做的话,它的行为会不符合预期:

    -
    wrongMap.has('bla')    // false
    +
    wrongMap.has('bla')    // false
     wrongMap.delete('bla') // false
     console.log(wrongMap)  // Map { bla: 'blaa', bla2: 'blaaa2' }

    无论如何,和正确用法比较起来,几乎没有什么不同: 

    -
    let myMap = new Map()
    +
    let myMap = new Map()
     myMap.set('bla','blaa')
     myMap.set('bla2','blaa2')
     console.log(myMap)  // Map { 'bla' => 'blaa', 'bla2' => 'blaa2' }
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/map/size/index.html b/files/zh-cn/web/javascript/reference/global_objects/map/size/index.html
    index 97a5d475c3..f793669b7b 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/map/size/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/map/size/index.html
    @@ -62,8 +62,8 @@ myMap.size // 3
     

    此页的兼容性表格请查阅:https://github.com/mdn/browser-compat-data 
    如果你想更新数据,请在GitHub上给我们发推送请求。

    -
    -

    异常提醒

    +
    +

    警告:异常提醒

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/map/values/index.html b/files/zh-cn/web/javascript/reference/global_objects/map/values/index.html index 46e4de8672..c85c3bcc36 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/map/values/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/map/values/index.html @@ -63,55 +63,7 @@ console.log(mapIter.next().value); // "baz"

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support38{{ CompatGeckoDesktop("20") }}{{CompatNo}}257.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}38{{ CompatGeckoMobile("20") }}{{CompatNo}}{{CompatNo}}8
    -
    +{{Compat}}

    查看

    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 e86e8064c2..2d3e550d2d 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 @@ -65,55 +65,7 @@ Math.abs(); // NaN

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    +{{Compat}}

    相关链接

    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 b50eb69568..c2dac17a81 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 @@ -55,54 +55,11 @@ Math.acos(2); // NaN +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
    • 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 2386375e80..aecf8f3e0a 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 @@ -54,54 +54,11 @@ Math.asin(2); // NaN
    +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
    • 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 0bdf09d234..ab53c9767c 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 @@ -50,54 +50,11 @@ Math.atan(0); // 0 +

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      + +{{Compat}} +

      相关链接

      • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
      • 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 b4ded024ac..840f177205 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 @@ -77,55 +77,7 @@ Math.atan2(15, 90) // 0.16514867741462683

        浏览器兼容性

        -

        {{ CompatibilityTable() }}

        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        +{{Compat}}

        相关链接

        diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/atanh/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/atanh/index.html index 6a0b373ddf..fe00a1eba2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/atanh/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/atanh/index.html @@ -71,55 +71,7 @@ Math.atanh(2); // NaN

        浏览器兼容性

        -
        {{CompatibilityTable}}
        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{CompatChrome("38")}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatOpera("25")}}{{CompatSafari("7.1")}}
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}8
        -
        +{{Compat}}

        相关链接

        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 4df408bf28..980c7a48fd 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 @@ -80,57 +80,7 @@ Math.cbrt(2); // 1.2599210498948734

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatNo}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - - +{{Compat}}

    另请参见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/ceil/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/ceil/index.html index 185d77ed54..4bd5f491f4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/ceil/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/ceil/index.html @@ -28,13 +28,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/ceil
    x
    一个数值。
    -
    -

    返回值

    - -

    大于或等于给定数字的最小整数。

    -
    +

    返回值

    + +

    大于或等于给定数字的最小整数。

    +

    描述

    由于 ceilMath 的静态方法,所以应该像这样使用:Math.ceil(),而不是作为你创建的 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 d0741e46a4..e15d870235 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 @@ -52,54 +52,11 @@ Math.cos(2 * Math.PI); // 1 +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
    • diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/cosh/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/cosh/index.html index f046070715..9378916bb3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/cosh/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/cosh/index.html @@ -69,55 +69,7 @@ Math.cosh(-1); // 1.5430806348152437

      浏览器兼容性

      -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatChrome("38")}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatOpera("25")}}{{CompatSafari("7.1")}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}8
      -
      +{{Compat}}

      相关链接

      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 adb71b9f29..a34a67156b 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 @@ -45,54 +45,11 @@ getNapier() // 2.718281828459045
    +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • 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 9161628dfb..2921e2dd84 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 @@ -48,54 +48,11 @@ Math.exp(1); // 2.718281828459045
    +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
    • 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 1b463f2c22..ff6cc83256 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 @@ -62,55 +62,7 @@ Math.expm1("foo") // NaN

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatNo}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
      -
      +{{Compat}}

      相关链接

      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 3f9deb45c0..20ce5698a0 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 @@ -12,7 +12,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/floor

      Math.floor() 返回小于或等于一个给定数字的最大整数。

      -

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

      +

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

      语法

      @@ -24,13 +24,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/floor
      x
      一个数字。
      -
      -

      返回值 

      - -

      一个表示小于或等于指定数字的最大整数的数字。

      -
      +

      返回值 

      + +

      一个表示小于或等于指定数字的最大整数的数字。

      +

      描述

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

      @@ -160,55 +159,7 @@ Math.ceil10(-59, 1); // -50

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      +{{Compat}}

      相关链接

      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 630c3b5d1c..786c555616 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 @@ -95,57 +95,9 @@ equal(0.1 + 0.2, 0.3); //true -

      浏览器兼容性

      +

      浏览器兼容性

      -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatChrome("38")}}{{CompatGeckoDesktop("26")}}{{CompatNo}}{{CompatOpera("25")}}{{CompatSafari("7.1")}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatNo}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}iOS 8
      -
      +{{Compat}}

      相关链接

      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 42c9565c28..d013d73d4b 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 @@ -86,56 +86,6 @@ Math.imul(0xfffffffe, 5) //-10 - - - -

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureFirefox (Gecko)ChromeInternet ExplorerOperaSafari
      Basic support{{ CompatGeckoDesktop("20") }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
      -
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureFirefox Mobile (Gecko)AndroidIE MobileOpera MobileSafari Mobile
      Basic support{{ CompatGeckoMobile("20") }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
      -
      +{{Compat}} diff --git a/files/zh-cn/web/javascript/reference/global_objects/math/index.html b/files/zh-cn/web/javascript/reference/global_objects/math/index.html index 4e67bcef28..b76793a7d8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/math/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/math/index.html @@ -43,13 +43,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math

      方法

      -

      需要注意的是,三角函数 sin()cos()tan()asin()acos()atan()atan2() 返回的值是弧度而非角度。

      +

      备注:需要注意的是,三角函数 sin()cos()tan()asin()acos()atan()atan2() 返回的值是弧度而非角度。

      若要转换,弧度除以 (Math.PI / 180) 即可转换为角度,同理,角度乘以这个数则能转换为弧度。

      -

      需要注意的是,很多 Math 函数都有一个精度,而且这个精度在不同实现中也是不相同的。这意味着不同的浏览器会给出不同的结果,甚至,在不同的系统或架构下,相同的 JS 引擎也会给出不同的结果!

      +

      备注:需要注意的是,很多 Math 函数都有一个精度,而且这个精度在不同实现中也是不相同的。这意味着不同的浏览器会给出不同的结果,甚至,在不同的系统或架构下,相同的 JS 引擎也会给出不同的结果!

      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 763340918a..eab6bc7621 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 @@ -45,54 +45,11 @@ getNatLog10() // 2.302585092994046
    +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • 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 f1d8fd9c23..a0be200539 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 @@ -45,54 +45,11 @@ getNatLog2() // 0.6931471805599453
    +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • 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 fc1a647ccc..88110bc541 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 @@ -78,55 +78,7 @@ Math.log(10); // 2.302585092994046

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    +{{Compat}}

    相关链接

    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 1f6d67437a..c4091b84d2 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 @@ -56,55 +56,7 @@ Math.log10("foo")// NaN

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatNo}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关链接

    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 43e10e9ed5..f85ebbf495 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 @@ -45,54 +45,11 @@ getLog10e() // 0.4342944819032518
    +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • 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 139283bc81..4ad2319f9e 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 @@ -59,55 +59,7 @@ Math.log1p("foo") // NaN

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatNo}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
      -
      +{{Compat}}

      相关链接

      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 1811e1b183..15bd670370 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 @@ -56,55 +56,7 @@ Math.log2("foo") // NaN

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatNo}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
      -
      +{{Compat}}

      相关链接

      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 79f6800f6e..f813c396be 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 @@ -45,54 +45,11 @@ getLog2e() // 1.4426950408889634
    +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • The {{jsxref("Global_Objects/Math", "Math")}} object it belongs to.
    • 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 068ffd7bd6..010d8819fd 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 @@ -98,58 +98,6 @@ if (x > boundary) {

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      +{{Compat}} -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      - -

      相关链接

      - -
        -
      • {{jsxref("Math.max()")}}
      • -
      +

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

      -
      function calculateCircumference (radius) {
      +
      function calculateCircumference (radius) {
         return 2 * Math.PI * radius;
       }
       
      @@ -58,55 +58,7 @@ calculateCircumference(1);  // 6.283185307179586

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      +{{Compat}}

      相关链接

      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 84c07215f2..1b37bb8dc5 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 @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random

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

      -

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

      +

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

      语法

      @@ -50,21 +50,21 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random

      这个例子返回了一个在指定值之间的随机整数。这个值不小于 min (如果 min 不是整数,则不小于 min 的向上取整数),且小于(不等于)max

      -
      function getRandomInt(min, max) {
      +
      function getRandomInt(min, max) {
         min = Math.ceil(min);
         max = Math.floor(max);
         return Math.floor(Math.random() * (max - min)) + min; //不含最大值,含最小值
       }
      -

      也许很容易想到用 Math.round() 来实现,但是这会导致你的随机数处于一个不均匀的分布,这可能不符合你的需求。

      +

      备注:也许很容易想到用 Math.round() 来实现,但是这会导致你的随机数处于一个不均匀的分布,这可能不符合你的需求。

      得到一个两数之间的随机整数,包括两个数在内

      上一个例子提到的函数 getRandomInt() 结果范围包含了最小值,但不含最大值。如果你的随机结果需要同时包含最小值和最大值,怎么办呢?  getRandomIntInclusive() 函数可以实现。

      -
      function getRandomIntInclusive(min, max) {
      +
      function getRandomIntInclusive(min, max) {
         min = Math.ceil(min);
         max = Math.floor(max);
         return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值,含最小值 
      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 8cc263a27d..4320c81ed1 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
      @@ -19,13 +19,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/round
       
      x
      一个数值。
      -
      -

      返回值

      - -

      给定数字的值四舍五入到最接近的整数。

      -
      +

      返回值

      + +

      给定数字的值四舍五入到最接近的整数。

      +

      描述

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

      @@ -155,53 +154,7 @@ round(1.005, 2); //1.01

      浏览器兼容性

      -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      +{{Compat}}

      相关链接

      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 3501c97fd8..b2ba39ed7a 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 @@ -50,7 +50,7 @@ Math.sign(); // NaN

      Polyfill

      -
      function sign(x) {
      +
      function sign(x) {
           x = +x ;// convert to a number
           if (x === 0 || isNaN(x))
               return x;
      @@ -95,55 +95,7 @@ Math.sign();      // NaN
       
       

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support38{{CompatGeckoDesktop("25")}}{{CompatNo}}25{{CompatNo}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
      -
      +{{Compat}}

      相关链接

      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 899783ca75..44f03bf2e7 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 @@ -24,7 +24,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/sinh

      双曲正弦的图像如下:

      -

      +

      示例

      @@ -55,61 +55,13 @@ Math.sinh("foo") // NaN

      该函数可以使用 {{jsxref("Math.exp()")}} 函数来实现:

      -
      function sinh(x){
      +
      function sinh(x){
           return  (Math.exp(x) - Math.exp(-x)) / 2;
       }

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatNo}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
      -
      +{{Compat}}

      相关链接

      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 413f66b993..7e9696145d 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 @@ -46,54 +46,11 @@ getRoot1_2() // 0.7071067811865476
      +

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      + +{{Compat}} +

      相关链接

      • 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 2c299fde7e..349a7674f8 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 @@ -41,54 +41,11 @@ getRoot2(); // 1.4142135623730951
      +

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      + +{{Compat}} +

      相关链接

      • 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 3ecf39169a..951894d06c 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 @@ -56,52 +56,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/tan +

        浏览器兼容性

        -

        {{ CompatibilityTable() }}

        -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        -

         

        + +{{Compat}} diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/epsilon/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/epsilon/index.html index 531b2ba929..df499c336d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/epsilon/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/epsilon/index.html @@ -57,55 +57,7 @@ equal = (Math.abs(x - y + z) < Number.EPSILON);

        浏览器兼容性

        -
        {{CompatibilityTable}}
        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("25.0")}}{{CompatNo}}{{CompatVersionUnknown}}9
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25.0")}}{{CompatNo}}{{CompatNo}}9
        -
        +{{Compat}}

        相关链接

        diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/max_safe_integer/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/max_safe_integer/index.html index 6891a1106c..c65b9bbfc6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/max_safe_integer/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/max_safe_integer/index.html @@ -47,55 +47,7 @@ Math.pow(2, 53) - 1 // 9007199254740991

        浏览器兼容性

        -
        {{CompatibilityTable}}
        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{CompatChrome("34")}}{{CompatGeckoDesktop("31")}}{{CompatNo}}{{CompatVersionUnknown}}9.0.2
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("32")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
        -
        +{{Compat}}

        相关链接

        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 db8250d873..8e8f11be4f 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 @@ -58,55 +58,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/MAX_VALUE

        浏览器兼容性

        -

        {{ CompatibilityTable() }}

        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        +{{Compat}}

        相关链接

        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 ba746ab29c..da639def78 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 @@ -45,54 +45,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/MIN_VALUE +

        浏览器兼容性

        -

        {{ CompatibilityTable() }}

        -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        + +{{Compat}} +

        相关链接

        • {{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 03f0bf5fb0..62906ea42a 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 @@ -47,55 +47,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/NaN

          浏览器兼容性

          -

          {{ CompatibilityTable() }}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          +{{Compat}}

          相关链接

          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 62112cb949..88189e6bf7 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 @@ -56,54 +56,11 @@ if (smallNumber == Number.NEGATIVE_INFINITY) { -

          浏览器规范

          -

          {{ CompatibilityTable() }}

          -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          + +

          浏览器兼容性

          + +{{Compat}} +

          相关链接

          • {{jsxref("Number.POSITIVE_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 705c63b712..69b12ad433 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 @@ -22,9 +22,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseFloat

            返回值

            -
            -
            给定值被解析成浮点数,如果无法被解析成浮点数,则返回NaN
            -
            +

            给定值被解析成浮点数,如果无法被解析成浮点数,则返回NaN

            描述

            @@ -49,57 +47,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/parseFloat -

            浏览器兼容性

            - -
            {{CompatibilityTable}}
            - -
            - - - - - - - - - - - - - - - - - - - -
            FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
            Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}
            -
            +

            浏览器兼容性

            -
            - - - - - - - - - - - - - - - - - - - - - -
            FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
            Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
            -
            +{{Compat}}

            相关链接

            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 e2b77c5d51..8e572bf740 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 @@ -71,55 +71,7 @@ if (bigNumber == Number.POSITIVE_INFINITY) {

            浏览器兼容性

            -

            {{ CompatibilityTable() }}

            - -
            - - - - - - - - - - - - - - - - - - - -
            FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
            Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
            -
            - -
            - - - - - - - - - - - - - - - - - - - - - -
            FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
            Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
            -
            +{{Compat}}

            相关链接

            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 250b8ebc76..1ab25c66cb 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 @@ -80,55 +80,7 @@ alert("77 .toExponential() is " + 77 .toExponential()); //输出 7.7e+1

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      +{{Compat}}

      相关链接

      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 1203b0c4fc..7e92f1908b 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 @@ -38,7 +38,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toFixed

      一个数值的字符串表现形式,不使用指数记数法,而是在小数点后有 digits(注:digits具体值取决于传入参数)位数字。该数值在必要时进行四舍五入,另外在必要时会用 0 来填充小数部分,以便小数部分有指定的位数。 如果数值大于 1e+21,该方法会简单调用 {{jsxref("Number.prototype.toString()")}}并返回一个指数记数法格式的字符串。

      -

      Warning: 浮点数不能精确地用二进制表示所有小数。这可能会导致意外的结果,例如 0.1 + 0.2 === 0.3 返回 false .

      +

      警告:浮点数不能精确地用二进制表示所有小数。这可能会导致意外的结果,例如 0.1 + 0.2 === 0.3 返回 false .

      示例

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/number/tolocalestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/number/tolocalestring/index.html index 20283fdfdd..acb1e71543 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/number/tolocalestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/number/tolocalestring/index.html @@ -24,7 +24,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

      查阅浏览器兼容性部分,了解哪些浏览器支持 localesoptions 参数,通过示例: 检查 localesoptions 参数的支持了解特征检测。

      -

      注意: ECMAScript 国际化 API,在 Firefox 29 中得以实施,增加了 locales 参数的 Number.toLocaleString 方法。如果参数为 undefined,此方法返回本地操作系统指定的位数,而 Firefox 的早期版本中返回阿拉伯语数字。这一变化已被报告为向后影响的兼容性问题并可能会被尽快修复。({{ bug(999003) }})

      +

      备注: ECMAScript 国际化 API,在 Firefox 29 中得以实施,增加了 locales 参数的 Number.toLocaleString 方法。如果参数为 undefined,此方法返回本地操作系统指定的位数,而 Firefox 的早期版本中返回阿拉伯语数字。这一变化已被报告为向后影响的兼容性问题并可能会被尽快修复。({{ bug(999003) }})

      {{page('/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat', '参数')}}
      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 ff4e3425c3..7bc5318e5c 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 @@ -74,55 +74,7 @@ console.log((1234.5).toPrecision(2)); // "1.2e+3"

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      +{{Compat}}

      相关链接

      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 ad95155237..87b075c6f8 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 @@ -26,54 +26,11 @@ Number.toSource();

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

      规范

      不是任何标准的一部分。在 JavaScript 1.3 被实现。

      +

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatUnknown() }}{{ CompatVersionUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
      -
      -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatVersionUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}
      -
      + +{{Compat}} +

      相关链接

      • {{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 7c438cb6f7..bafb633398 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 @@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number/toString
        radix
        -
        指定要用于数字到字符串的转换的基数(从2到36)。如果未指定 radix 参数,则默认值为 10。
        +
        指定要用于数字到字符串的转换的基数(从2到36)。如果未指定 radix 参数,则默认值为 10。

        异常信息

        @@ -90,55 +90,7 @@ console.log((-0xff).toString(2)); // 输出 '-11111111'

        浏览器兼容性

        -
        {{CompatibilityTable}}
        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        +{{Compat}}

        相关链接

        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 dc97f672f8..af9fb3c0ff 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 @@ -65,55 +65,7 @@ console.log(typeof num); // number

        浏览器兼容性

        -
        {{CompatibilityTable}}
        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        +{{Compat}}

        相关链接

        diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/__definegetter__/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/__definegetter__/index.html index b0229c493e..d8fb71db90 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/__definegetter__/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/__definegetter__/index.html @@ -47,55 +47,11 @@ console.log(o.gimmeFive); // 5

      规范

      不属于任何规范。

      -

      浏览器兼容性

      -
      - {{CompatibilityTable}}
      -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatIE("11")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      + +

      浏览器兼容性

      + +{{Compat}} +

      相关链接

      • {{jsxref("Object.prototype.__defineSetter__()")}}
      • diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/__definesetter__/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/__definesetter__/index.html index b854a96ea0..519bedad8e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/__definesetter__/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/__definesetter__/index.html @@ -32,55 +32,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/__defineSetter__

        __defineSetter__ 方法可以为一个已经存在的对象设置(新建或修改)访问器属性,而 {{jsxref("Operators/set", "对象字面量中的 set 语法", "", 1)}} 只能在新建一个对象时使用。

        规范

        不属于任何规范。

        -

        浏览器兼容性

        -
        - {{CompatibilityTable}}
        -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatIE("11")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        + +

        浏览器兼容性

        + +{{Compat}} +

        相关链接

        • {{jsxref("Object.prototype.__defineGetter__()")}}
        • diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/__lookupgetter__/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/__lookupgetter__/index.html index 52fe502257..5c722986ef 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/__lookupgetter__/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/__lookupgetter__/index.html @@ -59,55 +59,7 @@ Object.getOwnPropertyDescriptor(prototype, "foo").get

          浏览器兼容性

          -

          {{ CompatibilityTable() }}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatUnknown() }}{{CompatVersionUnknown() }}{{CompatVersionUnknown() }}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatVersionUnknown() }}{{CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatUnknown() }}{{ CompatUnknown() }}{{CompatVersionUnknown() }}
          -
          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/__lookupsetter__/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/__lookupsetter__/index.html index 859318a8bc..db8cff8eba 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/__lookupsetter__/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/__lookupsetter__/index.html @@ -77,55 +77,7 @@ Object.getOwnPropertyDescriptor(obj, 'foo').set;

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatIE("11")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}
          -
          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html index c81cacda30..4b8696d2ab 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html @@ -45,8 +45,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign

          在出现错误的情况下,例如,如果属性不可写,会引发{{jsxref("TypeError")}},如果在引发错误之前添加了任何属性,则可以更改target对象。

          -
          -

          注意,Object.assign 不会在那些source对象值为 {{jsxref("null")}} 或 {{jsxref("undefined")}} 的时候抛出错误。

          +
          +

          备注: Object.assign 不会在那些source对象值为 {{jsxref("null")}} 或 {{jsxref("undefined")}} 的时候抛出错误。

          Polyfill

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html index 74b6088e27..6e3f75cea7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html @@ -43,7 +43,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperty

          被传递给函数的对象。

          -

          在ES6中,由于 Symbol类型的特殊性,用Symbol类型的值来做对象的key与常规的定义或修改不同,而Object.defineProperty 是定义key为Symbol的属性的方法之一。

          +

          备注:在ES6中,由于 Symbol类型的特殊性,用Symbol类型的值来做对象的key与常规的定义或修改不同,而Object.defineProperty 是定义key为Symbol的属性的方法之一。

          描述

          @@ -94,9 +94,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperty

          描述符可拥有的键值

          -
          -
          - +
          @@ -128,8 +126,6 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperty
          -
          -

          如果一个描述符不具有 valuewritablegetset 中的任意一个键,那么它将被认为是一个数据描述符。如果一个描述符同时拥有 valuewritablegetset 键,则会产生一个异常。

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/entries/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/entries/index.html index ee59ebba46..db3fac1a89 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/entries/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/entries/index.html @@ -29,9 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/entries

          返回值

          -
          -
          给定对象自身可枚举属性的键值对数组。
          -
          +

          给定对象自身可枚举属性的键值对数组。

          描述

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/freeze/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/freeze/index.html index 6237badeea..6cc6d1c17a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/freeze/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/freeze/index.html @@ -86,7 +86,7 @@ Object.defineProperty(obj, 'foo', { value: 'eit' }); Object.setPrototypeOf(obj, { x: 20 }) obj.__proto__ = { x: 20 }
      -

      冻结数组

      +

      冻结数组

      let a = [0];
       Object.freeze(a); // 现在数组不能被修改了.
      diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html
      index 22df48a042..52875fee26 100644
      --- a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html
      +++ b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptors/index.html
      @@ -41,7 +41,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes
       
       

      创建子类的典型方法是定义子类,将其原型设置为超类的实例,然后在该实例上定义属性。这么写很不优雅,特别是对于 getters 和 setter 而言。 相反,您可以使用此代码设置原型:

      -
      function superclass() {}
      +
      function superclass() {}
       superclass.prototype = {
         // 在这里定义方法和属性
       };
      diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertysymbols/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertysymbols/index.html
      index f763ec6856..ef1b0ba509 100644
      --- a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertysymbols/index.html
      +++ b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertysymbols/index.html
      @@ -21,12 +21,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySym
       
      obj
      要返回 Symbol 属性的对象。
      -
      -

      返回值

      -
      -
      在给定对象自身上找到的所有 Symbol 属性的数组。
      +

      返回值

      + +

      在给定对象自身上找到的所有 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 ae9a9e5866..a7f274bbfa 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/getprototypeof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/getprototypeof/index.html @@ -17,16 +17,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf
      Object.getPrototypeOf(object)
       
      -
      -
      -

      参数obj

      -
      -
      要返回其原型的对象。
      -
      -

      返回值

      -
      -
      给定对象的原型。如果没有继承属性,则返回 {{jsxref("null")}} 。
      -
      +

      参数obj

      + +

      要返回其原型的对象。

      + +

      返回值

      + +

      给定对象的原型。如果没有继承属性,则返回 {{jsxref("null")}} 。

      {{EmbedInteractiveExample("pages/js/object-getprototypeof.html")}}

      @@ -42,7 +39,7 @@ Object.getPrototypeOf(reg) === RegExp.prototype; // true

      说明

      -

      Object.getPrototypeOf(Object)  不是  Object.prototype

      +

      备注:

      JavaScript中的 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 1a515b96ff..460aa64a98 100644
      --- a/files/zh-cn/web/javascript/reference/global_objects/object/isextensible/index.html
      +++ b/files/zh-cn/web/javascript/reference/global_objects/object/isextensible/index.html
      @@ -85,53 +85,7 @@ Object.isExtensible(1);
       
       

      浏览器兼容性

      -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureFirefox (Gecko)ChromeInternet ExplorerOperaSafari
      Basic support4 (2.0)69125.1
      -
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureFirefox Mobile (Gecko)AndroidIE MobileOpera MobileSafari Mobile
      Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
      -
      +{{Compat}}

      相关链接

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/isfrozen/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/isfrozen/index.html index cc428900b0..bb57973679 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/isfrozen/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/isfrozen/index.html @@ -22,12 +22,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isFrozen
      obj
      被检测的对象。
      -
      -

      返回值

      -
      -
      表示给定对象是否被冻结的{{jsxref("Boolean")}}。
      +

      返回值

      + +

      表示给定对象是否被冻结的{{jsxref("Boolean")}}。

      +

      描述

      一个对象是冻结的是指它不可{{jsxref("Object.isExtensible", "扩展")}},所有属性都是不可配置的,且所有数据属性(即没有getter或setter组件的访问器的属性)都是不可写的。

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/isprototypeof/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/isprototypeof/index.html index fb360e1ec1..98bef633c7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/isprototypeof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/isprototypeof/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf

      isPrototypeOf() 方法用于测试一个对象是否存在于另一个对象的原型链上。

      -

      isPrototypeOf() 与 {{jsxref("Operators/instanceof", "instanceof")}} 运算符不同。在表达式 "object instanceof AFunction"中,object 的原型链是针对 AFunction.prototype 进行检查的,而不是针对 AFunction 本身。

      +

      备注:isPrototypeOf() 与 {{jsxref("Operators/instanceof", "instanceof")}} 运算符不同。在表达式 "object instanceof AFunction"中,object 的原型链是针对 AFunction.prototype 进行检查的,而不是针对 AFunction 本身。

      语法

      @@ -107,57 +107,7 @@ console.log(Object.prototype.isPrototypeOf(baz)); // true

      浏览器兼容性

      -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - - -
      特性ChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
      基础支持{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - - -
      特性AndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      基础支持{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      +{{Compat}}

      相关链接

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/preventextensions/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/preventextensions/index.html index 09c0ff1c1a..72fb597281 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/preventextensions/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/preventextensions/index.html @@ -23,12 +23,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/preventExtensions
      obj
      将要变得不可扩展的对象。
      -
      -

      返回值

      -
      -
      已经不可扩展的对象。
      +

      返回值

      + +

      已经不可扩展的对象。

      +

      描述

      如果一个对象可以添加新的属性,则这个对象是可扩展的。Object.preventExtensions()将对象标记为不再可扩展,这样它将永远不会具有它被标记为不可扩展时持有的属性之外的属性。注意,一般来说,不可扩展对象的属性可能仍然可被删除。尝试将新属性添加到不可扩展对象将静默失败或抛出{{jsxref("TypeError")}}(最常见的情况是{{jsxref("Functions_and_function_scope/Strict_mode", "strict mode", "", 1)}}中,但不排除其他情况)。

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/proto/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/proto/index.html index d0ac7d3eb6..90f9790a0b 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/proto/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/proto/index.html @@ -13,11 +13,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/proto
      {{JSRef}}{{Deprecated_header}}
      -

      警告: 通过现代浏览器的操作属性的便利性,可以改变一个对象的 [[Prototype]] 属性, 这种行为在每一个JavaScript引擎和浏览器中都是一个非常慢且影响性能的操作,使用这种方式来改变和继承属性是对性能影响非常严重的,并且性能消耗的时间也不是简单的花费在 obj.__proto__ = ... 语句上, 它还会影响到所有继承来自该 [[Prototype]] 的对象,如果你关心性能,你就不应该在一个对象中修改它的 [[Prototype]]。相反, 创建一个新的且可以继承 [[Prototype]] 的对象,推荐使用 {{jsxref("Object.create()")}}。

      +

      警告:通过现代浏览器的操作属性的便利性,可以改变一个对象的 [[Prototype]] 属性, 这种行为在每一个JavaScript引擎和浏览器中都是一个非常慢且影响性能的操作,使用这种方式来改变和继承属性是对性能影响非常严重的,并且性能消耗的时间也不是简单的花费在 obj.__proto__ = ... 语句上, 它还会影响到所有继承来自该 [[Prototype]] 的对象,如果你关心性能,你就不应该在一个对象中修改它的 [[Prototype]]。相反, 创建一个新的且可以继承 [[Prototype]] 的对象,推荐使用 {{jsxref("Object.create()")}}。

      -

      警告:Object.prototype.__proto__ 已被大多数浏览器厂商所支持的今天,其存在和确切行为仅在ECMAScript 2015规范中被标准化为传统功能,以确保Web浏览器的兼容性。为了更好的支持,建议只使用 {{jsxref("Object.getPrototypeOf()")}}。

      +

      警告:Object.prototype.__proto__ 已被大多数浏览器厂商所支持的今天,其存在和确切行为仅在ECMAScript 2015规范中被标准化为传统功能,以确保Web浏览器的兼容性。为了更好的支持,建议只使用 {{jsxref("Object.getPrototypeOf()")}}。

      {{jsxref("Object.prototype")}} 的 __proto__  属性是一个访问器属性(一个getter函数和一个setter函数), 暴露了通过它访问的对象的内部[[Prototype]] (一个对象或 {{jsxref("Global_Objects/null", "null")}})。
      diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/setprototypeof/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/setprototypeof/index.html index 06de1bcc7c..a73a8c612c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/setprototypeof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/setprototypeof/index.html @@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
      -

      警告: 由于现代 JavaScript 引擎优化属性访问所带来的特性的关系,更改对象的 [[Prototype]]各个浏览器和 JavaScript 引擎上都是一个很慢的操作。其在更改继承的性能上的影响是微妙而又广泛的,这不仅仅限于 obj.__proto__ = ... 语句上的时间花费,而且可能会延伸到任何代码,那些可以访问任何[[Prototype]]已被更改的对象的代码。如果你关心性能,你应该避免设置一个对象的 [[Prototype]]。相反,你应该使用 {{jsxref("Object.create()")}}来创建带有你想要的[[Prototype]]的新对象。

      +

      警告:由于现代 JavaScript 引擎优化属性访问所带来的特性的关系,更改对象的 [[Prototype]]各个浏览器和 JavaScript 引擎上都是一个很慢的操作。其在更改继承的性能上的影响是微妙而又广泛的,这不仅仅限于 obj.__proto__ = ... 语句上的时间花费,而且可能会延伸到任何代码,那些可以访问任何[[Prototype]]已被更改的对象的代码。如果你关心性能,你应该避免设置一个对象的 [[Prototype]]。相反,你应该使用 {{jsxref("Object.create()")}}来创建带有你想要的[[Prototype]]的新对象。

      语法

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/tostring/index.html index 55310e85b0..23b9e41248 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/tostring/index.html @@ -35,7 +35,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/toString o.toString(); // 返回 [object Object]
      -
      注意:如 ECMAScript 5 和随后的 Errata 中所定义,从 JavaScript 1.8.5 开始,toString() 调用 {{jsxref("null")}} 返回[object Null],{{jsxref("undefined")}} 返回 [object Undefined]。请参阅下面的{{anch("Using_toString()_to_detect_object_class", "使用 toString() 检测对象类型")}}。
      +
      +

      备注:如 ECMAScript 5 和随后的 Errata 中所定义,从 JavaScript 1.8.5 开始,toString() 调用 {{jsxref("null")}} 返回[object Null],{{jsxref("undefined")}} 返回 [object Undefined]。请参阅下面的{{anch("Using_toString()_to_detect_object_class", "使用 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 6280feeb05..3fa248c3c5 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/valueof/index.html @@ -88,7 +88,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/valueOf
      myNumberType.valueOf()
      -

      注意:字符串上下文中的对象通过 {{jsxref("Object.toString", "toString()")}}方法转换,这与使用valueOf转换为原始字符串的{{jsxref("String")}}对象不同。所有对象都能转换成一个“[object 类型]”这种格式的字符串。但是很多对象不能转换为数字,布尔或函数。

      +

      备注:字符串上下文中的对象通过 {{jsxref("Object.toString", "toString()")}}方法转换,这与使用valueOf转换为原始字符串的{{jsxref("String")}}对象不同。所有对象都能转换成一个“[object 类型]”这种格式的字符串。但是很多对象不能转换为数字,布尔或函数。

      示例

      @@ -147,7 +147,7 @@ console.log( str2.valueOf() === str2 ); // false

      改写 .prototype.valueof

      -
      function MyNumberType(n) {
      +
      function MyNumberType(n) {
           this.number = n;
       }
       
      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 eaa80b6179..9e1dbd1322 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
      @@ -28,9 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/parseFloat
       
       

      返回值

      -
      -
      给定值被解析成浮点数。如果给定值不能被转换成数值,则会返回 {{jsxref("NaN")}}。
      -
      +

      给定值被解析成浮点数。如果给定值不能被转换成数值,则会返回 {{jsxref("NaN")}}。

      描述

      @@ -55,7 +53,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/parseFloat

      下面的例子都返回3.14

      -
      parseFloat(3.14);
      +
      parseFloat(3.14);
       parseFloat('3.14');
       parseFloat('  3.14  ');
       parseFloat('314e-2');
      @@ -74,7 +72,7 @@ parseFloat({ toString: function() { return "3.14" } });

      以下例子均返回 900719925474099300,当整数太大以至于不能被转换时将失去精度。

      -
      parseFloat(900719925474099267n);
      +
      parseFloat(900719925474099267n);
       parseFloat('900719925474099267n');

      规范

      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 6dd0b83e6b..d904b20451 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 @@ -26,8 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/parseInt
      string
      要被解析的值。如果参数不是一个字符串,则将其转换为字符串(使用  ToString 抽象操作)。字符串开头的空白符将会被忽略。
      radix {{optional_inline}}
      -
      236,表示字符串的基数。例如指定 16 表示被解析值是十六进制数。请注意,10不是默认值!
      -
      文章后面的描述解释了当参数 radix 不传时该函数的具体行为。
      +
      236,表示字符串的基数。例如指定 16 表示被解析值是十六进制数。请注意,10不是默认值!文章后面的描述解释了当参数 radix 不传时该函数的具体行为。

      返回值

      @@ -43,7 +42,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

      @@ -72,8 +71,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/parseInt

      要将一个数字转换为特定的 radix 中的字符串字段,请使用 thatNumber.toString(radix)函数。

      -
      -

      {{jsxref("BigInt")}}。警告: parseInt将 {{jsxref("BigInt")}}转换为{{jsxref("Number")}},并在这个过程中失去了精度。这是因为拖尾的非数字值,包括 "n",会被丢弃。

      +
      +

      警告:{{jsxref("BigInt")}}。警告: parseInt将 {{jsxref("BigInt")}}转换为{{jsxref("Number")}},并在这个过程中失去了精度。这是因为拖尾的非数字值,包括 "n",会被丢弃。

      示例

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/promise/any/index.html b/files/zh-cn/web/javascript/reference/global_objects/promise/any/index.html index b61b833f5f..df6841de79 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/promise/any/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/promise/any/index.html @@ -13,8 +13,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/any

      Promise.any() 接收一个{{JSxRef("Promise")}}可迭代对象,只要其中的一个 promise 成功,就返回那个已经成功的 promise 。如果可迭代对象中没有一个 promise 成功(即所有的 promises 都失败/拒绝),就返回一个失败的 promise 和{{JSxRef("Global_Objects/AggregateError", "AggregateError")}}类型的实例,它是 {{JSxRef("Error")}} 的一个子类,用于把单一的错误集合在一起。本质上,这个方法和{{JSxRef("Promise.all()")}}是相反的。

      -
      -

      注意! Promise.any() 方法依然是实验性的,尚未被所有的浏览器完全支持。它当前处于 TC39 第四阶段草案(Stage 4)

      +
      +

      警告:Promise.any() 方法依然是实验性的,尚未被所有的浏览器完全支持。它当前处于 TC39 第四阶段草案(Stage 4)

      语法

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/promise/finally/index.html b/files/zh-cn/web/javascript/reference/global_objects/promise/finally/index.html index 70fc6512cb..83fd96107e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/promise/finally/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/promise/finally/index.html @@ -49,7 +49,7 @@ p.finally(function() {

    -

    注意: 在finally回调中 throw(或返回被拒绝的promise)将以 throw() 指定的原因拒绝新的promise.

    +

    备注: 在finally回调中 throw(或返回被拒绝的promise)将以 throw() 指定的原因拒绝新的promise.

    示例

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/promise/index.html b/files/zh-cn/web/javascript/reference/global_objects/promise/index.html index dd878cb92d..8b6cd1cd19 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/promise/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/promise/index.html @@ -32,14 +32,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise

    因为 {{jsxref("Promise.then", "Promise.prototype.then")}} 和  {{jsxref("Promise.catch", "Promise.prototype.catch")}} 方法返回的是 promise, 所以它们可以被链式调用。

    -

    +

    -

    不要和惰性求值混淆: 有一些语言中有惰性求值和延时计算的特性,它们也被称为“promises”,例如 Scheme。JavaScript 中的 promise 代表的是已经正在发生的进程, 而且可以通过回调函数实现链式调用。 如果您想对一个表达式进行惰性求值,就考虑一下使用无参数的"箭头函数":  f = () =>表达式 来创建惰性求值的表达式使用 f() 求值。

    +

    备注: 有一些语言中有惰性求值和延时计算的特性,它们也被称为“promises”,例如 Scheme。JavaScript 中的 promise 代表的是已经正在发生的进程, 而且可以通过回调函数实现链式调用。 如果您想对一个表达式进行惰性求值,就考虑一下使用无参数的"箭头函数":  f = () =>表达式 来创建惰性求值的表达式使用 f() 求值。

    -

    注意: 如果一个 promise 已经被兑现(fulfilled)或被拒绝(rejected),那么我们也可以说它处于已敲定(settled)状态。您还会听到一个经常跟 promise 一起使用的术语:已决议(resolved),它表示 promise 已经处于已敲定(settled)状态,或者为了匹配另一个 promise 的状态被"锁定"了。Domenic Denicola 的 States and fates 中有更多关于 promise 术语的细节可以供您参考。

    +

    备注: 如果一个 promise 已经被兑现(fulfilled)或被拒绝(rejected),那么我们也可以说它处于已敲定(settled)状态。您还会听到一个经常跟 promise 一起使用的术语:已决议(resolved),它表示 promise 已经处于已敲定(settled)状态,或者为了匹配另一个 promise 的状态被"锁定"了。Domenic Denicola 的 States and fates 中有更多关于 promise 术语的细节可以供您参考。

    Promise的链式调用

    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 d733feaa6a..40aa69e021 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 @@ -27,9 +27,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/reject

    返回值

    -
    -
    一个给定原因了的被拒绝的 {{jsxref("Promise")}}。
    -
    +

    一个给定原因了的被拒绝的 {{jsxref("Promise")}}。

    描述

    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 cce699c0bc..4e50535f20 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 @@ -15,8 +15,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/resolve
    -
    -

    警告:不要在解析为自身的thenable 上调用Promise.resolve。这将导致无限递归,因为它试图展平无限嵌套的promise。一个例子是将它与Angular中的异步管道一起使用。在此处了解更多信息。

    +
    +

    警告:不要在解析为自身的thenable 上调用Promise.resolve。这将导致无限递归,因为它试图展平无限嵌套的promise。一个例子是将它与Angular中的异步管道一起使用。在此处了解更多信息。

    例如下例代码
    @@ -38,9 +38,7 @@ Promise.resolve(thenable)  //这会造成一个死循环
     
     

    参数

    -
    -
    value
    -
    +

    value

    将被Promise对象解析的参数,也可以是一个Promise对象,或者是一个thenable。

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/promise/then/index.html b/files/zh-cn/web/javascript/reference/global_objects/promise/then/index.html index 6717a21da3..558603380e 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/promise/then/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/promise/then/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/then
    {{EmbedInteractiveExample("pages/js/promise-then.html")}}
    -

    注意:如果忽略针对某个状态的回调函数参数,或者提供非函数 (nonfunction) 参数,那么 then 方法将会丢失关于该状态的回调函数信息,但是并不会产生错误。如果调用 thenPromise 的状态(fulfillment 或 rejection)发生改变,但是 then 中并没有关于这种状态的回调函数,那么 then 将创建一个没有经过回调函数处理的新 Promise 对象,这个新 Promise 只是简单地接受调用这个 then 的原 Promise 的终态作为它的终态。

    +

    备注:如果忽略针对某个状态的回调函数参数,或者提供非函数 (nonfunction) 参数,那么 then 方法将会丢失关于该状态的回调函数信息,但是并不会产生错误。如果调用 thenPromise 的状态(fulfillment 或 rejection)发生改变,但是 then 中并没有关于这种状态的回调函数,那么 then 将创建一个没有经过回调函数处理的新 Promise 对象,这个新 Promise 只是简单地接受调用这个 then 的原 Promise 的终态作为它的终态。

    语法

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/defineproperty/index.html b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/defineproperty/index.html index 661a9a7681..f5f1b6b523 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/defineproperty/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/defineproperty/index.html @@ -122,55 +122,7 @@ Object.defineProperty(p, 'name', {

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/deleteproperty/index.html b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/deleteproperty/index.html index 5d3f631758..6618dc9c23 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/deleteproperty/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/deleteproperty/index.html @@ -90,55 +90,7 @@ delete p.a; // "called: a"

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/get/index.html b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/get/index.html index 36d60fab7e..2bc3c917f3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/get/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/get/index.html @@ -119,55 +119,7 @@ p.a; //会抛出TypeError

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/getownpropertydescriptor/index.html b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/getownpropertydescriptor/index.html index 7640828b95..78df24c74d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/getownpropertydescriptor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/getownpropertydescriptor/index.html @@ -109,55 +109,7 @@ Object.getOwnPropertyDescriptor(p, 'a'); // TypeError is thrown

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/has/index.html b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/has/index.html index 64545b27d2..32bebb31c2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/has/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/has/index.html @@ -115,57 +115,9 @@ var p = new Proxy(obj, { -

    浏览器支持

    +

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    其他

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/ownkeys/index.html b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/ownkeys/index.html index d050bb0b71..316a273352 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/ownkeys/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/ownkeys/index.html @@ -118,57 +118,9 @@ console.log(Object.getOwnPropertyNames(p)); -

    浏览器兼容

    +

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("18")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    兼容性注意事项

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/set/index.html b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/set/index.html index 9857c06818..f98aa2ddd9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/set/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/proxy/proxy/set/index.html @@ -40,7 +40,7 @@ original_slug: Web/JavaScript/Reference/Global_Objects/Proxy/handler/set
    receiver
    最初被调用的对象。通常是 proxy 本身,但 handler 的 set 方法也有可能在原型链上,或以其他方式被间接地调用(因此不一定是 proxy 本身)。
    -

    比如:假设有一段代码执行 obj.name = "jen"obj 不是一个 proxy,且自身不含 name 属性,但是它的原型链上有一个 proxy,那么,那个 proxy 的 set() 处理器会被调用,而此时,obj 会作为 receiver 参数传进来。

    +

    备注:假设有一段代码执行 obj.name = "jen"obj 不是一个 proxy,且自身不含 name 属性,但是它的原型链上有一个 proxy,那么,那个 proxy 的 set() 处理器会被调用,而此时,obj 会作为 receiver 参数传进来。

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/rangeerror/index.html b/files/zh-cn/web/javascript/reference/global_objects/rangeerror/index.html index 72ca35e7ce..ede4ac91ad 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/rangeerror/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/rangeerror/index.html @@ -101,55 +101,7 @@ catch (e) {

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关连接

    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 2dcc165e43..be371ecde7 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 @@ -110,55 +110,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/ReferenceError

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html b/files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html index c122d6fe14..f6dbc30635 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html @@ -128,57 +128,9 @@ d.getFullYear(); // 1776 -

    浏览器兼容

    +

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support49{{CompatGeckoDesktop(42)}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile(42)}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/reflect/defineproperty/index.html b/files/zh-cn/web/javascript/reference/global_objects/reflect/defineproperty/index.html index 9fc242fd8f..6524839fe7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/reflect/defineproperty/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/reflect/defineproperty/index.html @@ -40,8 +40,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Reflect/defineProperty

    Reflect.defineProperty 方法允许精确添加或修改对象上的属性。更多的细节请参阅类似的{{jsxref("Object.defineProperty")}} 。

    -
    -

    区别:Object.defineProperty 返回一个对象,或者如果属性没有被成功定义,抛出一个 {{jsxref("TypeError")}} 。 相比之下,Reflect.defineProperty方法只返回一个 {{jsxref("Boolean")}} ,来说明该属性是否被成功定义。

    +
    +

    备注:Object.defineProperty 返回一个对象,或者如果属性没有被成功定义,抛出一个 {{jsxref("TypeError")}} 。 相比之下,Reflect.defineProperty方法只返回一个 {{jsxref("Boolean")}} ,来说明该属性是否被成功定义。

    示例

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/reflect/deleteproperty/index.html b/files/zh-cn/web/javascript/reference/global_objects/reflect/deleteproperty/index.html index 1a8b8da0ec..c3f9987c9d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/reflect/deleteproperty/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/reflect/deleteproperty/index.html @@ -76,55 +76,7 @@ Reflect.deleteProperty(Object.freeze({foo: 1}), "foo"); // false

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support49{{CompatGeckoDesktop(42)}}{{CompatNo}}{{CompatNo}}10
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}49{{CompatGeckoMobile(42)}}{{CompatNo}}{{CompatNo}}10
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/reflect/getownpropertydescriptor/index.html b/files/zh-cn/web/javascript/reference/global_objects/reflect/getownpropertydescriptor/index.html index e4fdfe36a0..a9c4f7c1e4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/reflect/getownpropertydescriptor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/reflect/getownpropertydescriptor/index.html @@ -81,55 +81,7 @@ Object.getOwnPropertyDescriptor("foo", 0);

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support49{{CompatGeckoDesktop(42)}}{{CompatNo}}{{CompatNo}}10
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}49{{CompatGeckoMobile(42)}}{{CompatNo}}{{CompatNo}}10
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/reflect/has/index.html b/files/zh-cn/web/javascript/reference/global_objects/reflect/has/index.html index 3b44079e0d..4fc0aafed7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/reflect/has/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/reflect/has/index.html @@ -75,55 +75,7 @@ Reflect.has(obj, "dormitory"); // false

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support49{{CompatGeckoDesktop(42)}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile(42)}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关连接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/reflect/isextensible/index.html b/files/zh-cn/web/javascript/reference/global_objects/reflect/isextensible/index.html index a10658ab18..232f92f148 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/reflect/isextensible/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/reflect/isextensible/index.html @@ -89,55 +89,7 @@ Object.isExtensible(1);

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support49{{CompatGeckoDesktop(42)}}{{CompatNo}}{{CompatNo}}10
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}49{{CompatGeckoMobile(42)}}{{CompatNo}}{{CompatNo}}10
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/@@search/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/@@search/index.html index 19a14cdf19..8dfb7513f7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/@@search/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/@@search/index.html @@ -91,55 +91,7 @@ console.log(result); // 3

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop(49)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(49)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/@@species/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/@@species/index.html index a667841afb..aa8a496a11 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/@@species/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/@@species/index.html @@ -53,55 +53,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/@@species

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop("49")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("49")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/@@split/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/@@split/index.html index 213f37b1e7..e60c9eaaaf 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/@@split/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/@@split/index.html @@ -89,55 +89,7 @@ console.log(result); // ["(2016)", "(01)", "(02)"]

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop(49)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(49)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/compile/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/compile/index.html index b46e92ef6b..1f622c4146 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/compile/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/compile/index.html @@ -74,55 +74,7 @@ regexObj.compile("new foo", "g");

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    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 549dd3d494..172d75ef0f 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 @@ -55,10 +55,10 @@ var result = re.exec('The Quick Brown Fox Jumps Over The Lazy Dog'); - - - - + + + + @@ -137,8 +137,8 @@ while ((myArray = myRe.exec(str)) !== null) { Found ab. Next match starts at 9 -
    -

    注意:不要把正则表达式字面量(或者{{jsxref("RegExp")}}构造器)放在 while 条件表达式里。由于每次迭代时 {{jsxref("RegExp.lastIndex", "lastIndex")}} 的属性都被重置,如果匹配,将会造成一个死循环。并且要确保使用了'g'标记来进行全局的匹配,否则同样会造成死循环。

    +
    +

    警告:不要把正则表达式字面量(或者{{jsxref("RegExp")}}构造器)放在 while 条件表达式里。由于每次迭代时 {{jsxref("RegExp.lastIndex", "lastIndex")}} 的属性都被重置,如果匹配,将会造成一个死循环。并且要确保使用了'g'标记来进行全局的匹配,否则同样会造成死循环。

    结合 RegExp 字面量使用 exec()

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/flags/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/flags/index.html index e5ffd31071..a53c5b02e7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/flags/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/flags/index.html @@ -57,55 +57,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/flags

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    -
    对象属性/索引描述例子对象属性/索引描述例子
    result
    - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("37")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    另见

    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 95fbabc9d0..d22d0a6fd9 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 @@ -49,54 +49,11 @@ console.log(regex.global) // true +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • {{jsxref("RegExp.prototype.ignoreCase")}}
    • 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 c1802df75a..afaa21ee72 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 @@ -49,54 +49,11 @@ console.log(regex.ignoreCase) // true +

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      + +{{Compat}} +

      相关链接

      • {{jsxref("RegExp.prototype.global")}}
      • 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 c697ad26c4..cfbeceef06 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 @@ -207,8 +207,8 @@ console.log(/[^.]+/.exec(url)[0].substr(7)); // logs "xxx"
    -
    -

    使用浏览器内建的URL API而非正则表达式来解析URL是更好的做法

    +
    +

    备注:使用浏览器内建的URL API而非正则表达式来解析URL是更好的做法

    规范

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html index ede21a2dfa..0df63feb1d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/input/index.html @@ -38,55 +38,7 @@ RegExp.$_; // "hi world!"

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    另见

    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 ddfe60c595..4201b4649b 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 @@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/RegExp/lastIndex
    {{js_property_attributes(1,0,0)}}

    语法

    -
    lastIndex = regExpObj.lastIndex;
    +
    lastIndex = regExpObj.lastIndex;

    描述

    只有正则表达式使用了表示全局检索的 "g" 标志时,该属性才会起作用。此时应用下面的规则:

      @@ -63,54 +63,11 @@ console.log(re.lastIndex);
    +

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    + +{{Compat}} +

    相关链接

    • {{jsxref("RegExp.prototype.ignoreCase")}}
    • diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/lastmatch/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/lastmatch/index.html index 74bf3f095d..919978f6ff 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/lastmatch/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/lastmatch/index.html @@ -37,55 +37,7 @@ RegExp['$&']; // "hi"

      浏览器兼容性

      -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      +{{Compat}}

      另见

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/lastparen/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/lastparen/index.html index f7fb73f49f..959d012b13 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/lastparen/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/lastparen/index.html @@ -37,55 +37,7 @@ RegExp['$+']; // "hi"

      浏览器兼容性

      -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      +{{Compat}}

      另见

      diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/leftcontext/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/leftcontext/index.html index 9a0a93d3e4..c14364c4db 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/leftcontext/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/leftcontext/index.html @@ -37,55 +37,7 @@ RegExp['$`']; // "hello "

      浏览器兼容性

      -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      +{{Compat}}

      另见

      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 54b99c15ad..cd0de7293c 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 @@ -50,54 +50,11 @@ console.log(regex.multiline) // true +

      浏览器兼容性

      -

      {{ CompatibilityTable() }}

      -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
      -
      + +{{Compat}} +

      相关链接

      • {{jsxref("RegExp.prototype.global")}}
      • diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/n/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/n/index.html index 3b961acf2d..0fa992d176 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/n/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/n/index.html @@ -47,57 +47,9 @@ RegExp.$2; // "Smith"

        非标准. 不属于当前的任何规范.

        -

        浏览器适配

        - -
        {{CompatibilityTable}}
        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        +

        浏览器兼容性

        + +{{Compat}}

        参见

        diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/regexp/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/regexp/index.html index 85e5fccd83..8ade9bd6eb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/regexp/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/regexp/index.html @@ -102,7 +102,8 @@ new RegExp('ab+c', 'i') // 构造函数

        参见

        diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/rightcontext/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/rightcontext/index.html index d47f844db5..9c33ad6a73 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/rightcontext/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/rightcontext/index.html @@ -37,55 +37,7 @@ RegExp["$'"]; // " world!"

        浏览器兼容性

        -
        {{CompatibilityTable}}
        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        +{{Compat}}

        另见

        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 191f1e0feb..375bb2eaf9 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 @@ -50,57 +50,9 @@ console.log(regex.source); // "fooBar",不包含 /.../ 和 "ig"。 -

        浏览器兼容性

        +

        浏览器兼容性

        -
        {{CompatibilityTable}}
        - -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        - -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
        -
        +{{Compat}}

        相关链接

        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 a1007ec670..114e4a0a68 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 @@ -52,54 +52,11 @@ alert(foo.toString()); // 显示 "/bar/g" +

        浏览器兼容性

        -

        {{ CompatibilityTable() }}

        -
        - - - - - - - - - - - - - - - - - - - -
        FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        -
        - - - - - - - - - - - - - - - - - - - - - -
        FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
        Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
        -
        + +{{Compat}} +

        相关链接

        • {{jsxref("Object.prototype.toString()")}}
        • diff --git a/files/zh-cn/web/javascript/reference/global_objects/regexp/unicode/index.html b/files/zh-cn/web/javascript/reference/global_objects/regexp/unicode/index.html index ee559098cd..5e9f39fdb7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/regexp/unicode/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/regexp/unicode/index.html @@ -48,57 +48,7 @@ console.log(regex.unicode); // true

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{CompatChrome(50)}}12 (case folding 13){{CompatGeckoDesktop(46)}}{{CompatNo}}3710
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatNo}}{{CompatChrome(50)}}{{CompatGeckoMobile(46)}}{{CompatNo}}{{CompatVersionUnknown}}10
          -
          +{{Compat}}

          另见

          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 b8df81ca52..9fb4ae67ae 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 @@ -62,55 +62,7 @@ mySet.has("bar") // false

          浏览器兼容性

          -

          {{ CompatibilityTable() }}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support38{{CompatGeckoDesktop("19.0")}}11257.1
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{ CompatNo() }}25{{CompatGeckoMobile("19.0")}}{{ CompatNo() }}{{ CompatNo() }}8
          -
          +{{Compat}}

          相关链接

          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 92eef27f5f..66f0fa83cb 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 @@ -62,55 +62,7 @@ mySet.has("foo"); // 返回 false,"foo" 已经成功删除

          浏览器兼容性

          -

          {{ CompatibilityTable() }}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support38{{CompatGeckoDesktop("13.0")}}11257.1
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{ CompatNo() }}38{{CompatGeckoMobile("13.0")}}{{ CompatNo() }}{{ CompatNo() }}8
          -
          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/entries/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/entries/index.html index 8f737249ae..5e64cd0069 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/set/entries/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/set/entries/index.html @@ -53,57 +53,9 @@ console.log(setIter.next().value); // ["baz", "baz"] -

          浏览器兼容性 

          +

          浏览器兼容性

          -

          {{CompatibilityTable}}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support38{{ CompatGeckoDesktop("24") }}{{CompatNo}}257.1
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatNo}}38{{ CompatGeckoMobile("24") }}{{CompatNo}}{{CompatNo}}8
          -
          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/set/foreach/index.html b/files/zh-cn/web/javascript/reference/global_objects/set/foreach/index.html index bfef87e0bd..09706d3444 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/set/foreach/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/set/foreach/index.html @@ -86,55 +86,7 @@ new Set(["foo", "bar", undefined]).forEach(logSetElements);

          浏览器兼容性

          -

          {{CompatibilityTable}}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{ CompatChrome(38) }}{{CompatGeckoDesktop("25.0")}}{{ CompatIE("11") }}257.1
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatNo}}38{{CompatGeckoMobile("25.0")}}{{CompatNo}}{{CompatNo}}8
          -
          +{{Compat}}

          参见

          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 0174ccd5bc..12c6ad6073 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 @@ -35,7 +35,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/has

          使用 has 方法

          -
          var mySet = new Set();
          +
          var mySet = new Set();
           mySet.add('foo');
           
           mySet.has('foo');  // 返回 true
          @@ -68,55 +68,7 @@ set1.add({'key1': 1}); // 现在 set1 中有2条(不同引用的)对象了浏览器兼容性
           
          -

          {{ CompatibilityTable() }}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support38{{CompatGeckoDesktop("13.0")}}11257.1
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{ CompatNo() }}38{{CompatGeckoMobile("13.0")}}{{ CompatNo() }}{{ CompatNo() }}iOS 8
          -
          +{{Compat}}

          相关连接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/sharedarraybuffer/index.html b/files/zh-cn/web/javascript/reference/global_objects/sharedarraybuffer/index.html index 426f293f00..d5c1f3d3ff 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/sharedarraybuffer/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/sharedarraybuffer/index.html @@ -18,8 +18,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer

          SharedArrayBuffer 对象用来表示一个通用的,固定长度的原始二进制数据缓冲区,类似于 {{jsxref("ArrayBuffer")}} 对象,它们都可以用来在共享内存(shared memory)上创建视图。与 ArrayBuffer 不同的是,SharedArrayBuffer 不能被分离。

          -
          -

          请注意,作为对Spectre的响应,所有主流浏览器均默认于2018年1月5日禁用SharedArrayBuffer。 Chrome在启用了网站隔离功能的平台上的v67中重新启用了该功能,以防止出现Spectre风格的漏洞。

          +
          +

          备注:作为对Spectre的响应,所有主流浏览器均默认于2018年1月5日禁用SharedArrayBuffer。 Chrome在启用了网站隔离功能的平台上的v67中重新启用了该功能,以防止出现Spectre风格的漏洞。

          {{EmbedInteractiveExample("pages/js/sharedarraybuffer-constructor.html")}}

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/@@iterator/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/@@iterator/index.html index abbf9ae0b8..65ea0ae37f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/@@iterator/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/@@iterator/index.html @@ -78,57 +78,7 @@ for (var v of string) {

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          基本支持{{CompatVersionUnknown}}{{CompatGeckoDesktop("36")}} [1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          基本支持{{CompatNo}}{{CompatVersionUnknown}}{{CompatGeckoMobile("36")}} [1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
          -
          - -

          [1] From Gecko 17 (Firefox 17 / Thunderbird 17 / SeaMonkey 2.14) to Gecko 26 (Firefox 26 / Thunderbird 26 / SeaMonkey 2.23 / Firefox OS 1.2) the iterator property was used (bug 907077), and from Gecko 27 to Gecko 35 the "@@iterator" placeholder was used. In Gecko 36 (Firefox 36 / Thunderbird 36 / SeaMonkey 2.33), the @@iterator symbol got implemented (bug 918828).

          +{{Compat}}

          相关链接

          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 43ab947d68..25608cd5ee 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 @@ -13,9 +13,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/anchor

          概述

          -
          -

          已废弃
          - 该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。

          +
          +

          警告:该特性已经从 Web 标准中删除,虽然一些浏览器目前仍然支持它,但也许会在未来的某个时间停止支持,请尽量不要使用该特性。

          anchor() 方法创建一个 {{HTMLElement("a")}} HTML 锚元素,被用作超文本靶标(hypertext target)。

          @@ -75,59 +74,7 @@ document.body.innerHTML = myString.anchor("contents_anchor");

          浏览器兼容性

          -

          {{ CompatibilityTable() }}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{ CompatVersionUnknown() }}{{ CompatGeckoDesktop("1.0") }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatGeckoMobile("1.0") }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          - -

          Gecko-specific notes

          - -

          从{{gecko("17")}}开始  " (引号) 被 HTML引用字符 &quot所替代;在字符串中申请命名参数.

          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/big/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/big/index.html index e45ae963c1..0d6104c911 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/big/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/big/index.html @@ -8,7 +8,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/big

          big()方法的作用是创建一个使字符串显示大号字体的{{HTMLElement("big")}}标签。

          -

          使用说明:  <big> 元素在HTML5中已经被移除了,不应该再使用它。 取而代之的是web开发人员应该使用CSS 属性。

          +

          备注:  <big> 元素在HTML5中已经被移除了,不应该再使用它。 取而代之的是web开发人员应该使用CSS 属性。

          语法

          @@ -65,55 +65,7 @@ console.log(worldString.fontsize(7)); // <fontsize=7>Hello, world</font

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/blink/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/blink/index.html index e423d8fbfd..a9767ac29a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/blink/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/blink/index.html @@ -60,55 +60,7 @@ console.log(worldString.strike()); // <strike>Hello, world</strike>

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/bold/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/bold/index.html index 43d6f9d448..07ab6f5e5f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/bold/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/bold/index.html @@ -60,55 +60,7 @@ console.log(worldString.strike()); // <strike>Hello, world</strike>

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          +{{Compat}}

          相关连接

          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 0e024365f2..bae0698030 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 @@ -217,55 +217,7 @@ function getWholeCharAndI (str, i) {

          浏览器兼容性

          -

          {{ CompatibilityTable() }}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          +{{Compat}}

          相关链接

          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 ad5bd693df..149492f9d0 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 @@ -39,8 +39,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/charCodeAt

          Unicode 码点(code points)的范围从 01114111 (0x10FFFF)。开头的 128 个 Unicode 编码单元和 ASCII 字符编码一样。(关于 Unicode 的更多信息,可查看 JavaScript Guide。)

          -
          -

          注意:charCodeAt 总是返回一个小于 65,536 的值。这是因为高位编码单元(higher code point)使用一对(低位编码 lower valued)代理伪字符("surrogate" pseudo-characters)来表示,从而构成一个真正的字符。

          +
          +

          备注:charCodeAt 总是返回一个小于 65,536 的值。这是因为高位编码单元(higher code point)使用一对(低位编码 lower valued)代理伪字符("surrogate" pseudo-characters)来表示,从而构成一个真正的字符。

          因此,为了检查(或重现)65536 及以上编码字符的完整字符,需要在获取 charCodeAt(i) 的值的同时获取 charCodeAt(i+1) 的值(如同用两个字母操纵一个字符串),或者改为获取 codePointAt(i) 的值。参看下面例 2 和例 3。

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/codepointat/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/codepointat/index.html index 9a204e9c4b..d5dc1ad036 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/codepointat/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/codepointat/index.html @@ -113,55 +113,7 @@ if (!String.prototype.codePointAt) {

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - -
          特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari
          基本支持{{CompatChrome("41")}}{{CompatGeckoDesktop("29")}}11{{CompatOpera("28")}}{{CompatNo}}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          特性AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          基本支持{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("29")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
          -
          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/fixed/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/fixed/index.html index 6fd1d90c0d..5b410acc42 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/fixed/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/fixed/index.html @@ -58,55 +58,7 @@ console.log(worldString.fixed()); // "<tt>Hello, world</tt>"

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - -
          版本ChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          版本AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/fontcolor/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/fontcolor/index.html index 551cb5ffa0..05d9645258 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/fontcolor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/fontcolor/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/fontcolor

          fontcolor()方法创建一个{{HTMLElement("font")}}的HTML元素让字符串被显示成指定的字体颜色。

          -

          使用注意:<font>元素已经在在HTML5中被移除并且不应该在使用。替代的是,web开发者应该使用CSS属性。

          +

          备注:<font>元素已经在在HTML5中被移除并且不应该在使用。替代的是,web开发者应该使用CSS属性。

          语法

          @@ -32,9 +32,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/fontcolor

          返回值

          -
          -
          一个包含一个{{HTMLElement("font")}} HTML元素的字符串。
          -
          +

          一个包含一个{{HTMLElement("font")}} HTML元素的字符串。

          描述

          @@ -82,55 +80,7 @@ console.log(worldString.fontcolor('FF00') + ' is red in hexadecimal'

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox(Gecko)Internet ExplorerOperaSafari
          Basic Support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile(Gecko)IE MobileOpera MobileSafari Mobile
          Basic Support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          +{{Compat}}

          也可以看看

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/fontsize/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/fontsize/index.html index 005cfe0fb0..339b250b82 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/fontsize/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/fontsize/index.html @@ -8,7 +8,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/fontsize

          The fontsize() method creates a {{HTMLElement("font")}} HTML element that causes a string to be displayed in the specified font size.

          -

          Usage note: The <font> element has been removed in HTML5 and shouldn't be used anymore. Instead web developers should use CSS properties.

          +

          备注: The <font> element has been removed in HTML5 and shouldn't be used anymore. Instead web developers should use CSS properties.

          语法

          @@ -72,55 +72,7 @@ console.log(worldString.fontsize(7)); // <font size="7">Hello, world</f

          浏览器兼容性

          -
          {{CompatibilityTable}}
          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
          -
          +{{Compat}}

          相关链接

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/fromcodepoint/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/fromcodepoint/index.html index d7c6ad0ccd..5a8a4a6c14 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/fromcodepoint/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/fromcodepoint/index.html @@ -20,13 +20,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/fromCodePoint
          num1, ..., numN
          一串 Unicode 编码位置,即“代码点”。
          -
          -

          返回值

          - -

          使用指定的 Unicode 编码位置创建的字符串。

          -
          +

          返回值

          + +

          使用指定的 Unicode 编码位置创建的字符串。

          +

          异常

          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 6784bfb61f..97b7bf23aa 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 @@ -25,12 +25,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/includes
          要在此字符串中搜索的字符串。
          position {{optional_inline}}
          从当前字符串的哪个索引位置开始搜寻子字符串,默认值为 0
          -
          -

          返回值

          -
          -
          如果当前字符串包含被搜寻的字符串,就返回 true;否则返回 false
          +

          返回值

          +

          如果当前字符串包含被搜寻的字符串,就返回 true;否则返回 false

          +

          描述

          这个方法可以帮你判断一个字符串是否包含另外一个字符串。

          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 8a6daf8511..26777dcf2e 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 @@ -118,7 +118,7 @@ new String(thing)
          -
          和其他语言不同,javascript 的字符串不区分单引号和双引号,所以不论是单引号还是双引号的字符串,上面的转义字符都能运行 。
          +

          备注:和其他语言不同,javascript 的字符串不区分单引号和双引号,所以不论是单引号还是双引号的字符串,上面的转义字符都能运行 。

          长字符串

          @@ -203,7 +203,9 @@ console.log(eval(s2)); // returns the string "2 + 2"
          console.log(eval(s2.valueOf())); // returns the number 4
           
          -
          注意: 其他的将字符串对象转换成基本字符串的方法可以及参考 StringView – a C-like representation of strings based on typed arrays.
          +
          +

          备注: 其他的将字符串对象转换成基本字符串的方法可以及参考 StringView – a C-like representation of strings based on typed arrays.

          +

          属性

          @@ -231,7 +233,7 @@ console.log(eval(s2)); // returns the string "2 + 2"

          字符串泛型方法

          -

          字符串泛型是非标准的已弃用并且会在不远的将来删除。注意,你不能依靠他们的跨浏览器,而不使用下面提供的垫片。

          +

          警告:字符串泛型是非标准的已弃用并且会在不远的将来删除。注意,你不能依靠他们的跨浏览器,而不使用下面提供的垫片。

          应该避免在 Javascript 1.6 (Firefox 浏览器的 JS 引擎)中使用(虽然也支持)将其他对象转化为字符的方法,因为方法并没有成为 ECMA 标准:

          @@ -293,57 +295,7 @@ for (let i = 0, n = inputValues.length; i < n; ++i) {

          浏览器兼容性

          -

          {{ CompatibilityTable() }}

          - -
          - - - - - - - - - - - - - - - - - - - -
          FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
          Basic support0.2{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          - -
          - - - - - - - - - - - - - - - - - - - - - -
          FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
          Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
          -
          - -

          +{{Compat}}

          相关链接

          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 b976a54b65..c12312dba9 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 @@ -18,7 +18,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/indexOf -
          Note: For the Array method, see {{jsxref("Array.prototype.indexOf()")}}.
          +
          +

          备注: For the Array method, see {{jsxref("Array.prototype.indexOf()")}}.

          +

          语法

          diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/italics/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/italics/index.html index 91f574b4bf..d94a82229d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/italics/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/italics/index.html @@ -48,57 +48,9 @@ console.log(worldString.strike()); // Hello, world
    -

    Browser compatibility

    +

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    See also

    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 297d9f6d89..e963adf719 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 @@ -20,11 +20,10 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf
    一个字符串,表示被查找的值。如果searchValue是空字符串,则返回fromIndex
    fromIndex{{optional_inline}}
    待匹配字符串searchValue的开头一位字符从 str的第fromIndex位开始向左回向查找。fromIndex默认值是 +Infinity。如果 fromIndex >= str.length ,则会搜索整个字符串。如果 fromIndex < 0 ,则等同于 fromIndex == 0
    -
    -

    返回值

    -
    +

    返回值

    +

    返回指定值最后一次出现的索引(该索引仍是以从左至右0开始记数的),如果没找到则返回-1。

    描述

    @@ -41,8 +40,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/lastIndexOf 'canal'.lastIndexOf('', 2); // returns 2
    -
    -

    Note: 'abab'.lastIndexOf('ab', 2) 将返回 2 而不是 0, 因为fromIndex只限制待匹配字符串的开头。

    +
    +

    备注:'abab'.lastIndexOf('ab', 2) 将返回 2 而不是 0, 因为fromIndex只限制待匹配字符串的开头。

    (例如'abadefgabm'.lastIndexOf('ab', 7) 返回7,虽然查找的'ab'中的b已经在 index=8的位置了从index=7的a处向左查找仍是能找到自身a加上其后连成ab,因为fromIndex指的是待匹配字符串的开头那一个)

    @@ -101,55 +100,7 @@ console.log("The index of 'new' from the end is " + anyString.lastIndexOf("new")

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    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 afef2dd204..f75e5eabdb 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 @@ -62,55 +62,7 @@ console.log("The empty string is has a length of " + empty.length);

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    +{{Compat}}

    相关链接

    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 57bd74a182..48e537cb96 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 @@ -38,9 +38,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match
  • input: 搜索的字符串.
  • -
    -
    一个{{jsxref("Array")}},其内容取决于global(g)标志的存在与否,如果未找到匹配则为{{jsxref("null")}}。
    -
    +

    一个{{jsxref("Array")}},其内容取决于global(g)标志的存在与否,如果未找到匹配则为{{jsxref("null")}}。

    描述

    @@ -60,7 +58,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/match

    在下例中,使用 match 查找 "Chapter" 紧跟着 1 个或多个数值字符,再紧跟着一个小数点和数值字符 0 次或多次。正则表达式包含 i 标志,因此大小写会被忽略。

    -
    var str = 'For more information, see Chapter 3.4.5.1';
    +
    var str = 'For more information, see Chapter 3.4.5.1';
     var re = /see (chapter \d+(\.\d)*)/i;
     var found = str.match(re);
     
    @@ -82,7 +80,7 @@ console.log(found);
     
     

    下例展示了 match 使用 global 和 ignore case 标志。A-E、a-e 的所有字母将会作为一个数组的元素返回。

    -
    var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
    +
    var str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
     var regexp = /[A-E]/gi;
     var matches_array = str.match(regexp);
     
    @@ -91,7 +89,7 @@ console.log(matches_array);
     
     

    使用match(),不传参数

    -
    var str = "Nothing will come of nothing.";
    +
    var str = "Nothing will come of nothing.";
     
     str.match();   // returns [""]
    @@ -99,7 +97,7 @@ str.match(); // returns [""]

    当参数是一个字符串或一个数字,它会使用new RegExp(obj)来隐式转换成一个 {{jsxref("RegExp")}}。如果它是一个有正号的正数,RegExp() 方法将忽略正号。

    -
    var str1 = "NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.",
    +
    var str1 = "NaN means not a number. Infinity contains -Infinity and +Infinity in JavaScript.",
         str2 = "My grandfather is 65 years old and My grandmother is 63 years old.",
         str3 = "The contract was declared null and void.";
     str1.match("number");   // "number" 是字符串。返回["number"]
    @@ -145,64 +143,7 @@ str3.match(null);       // 返回["null"]

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -

    Firefox 特殊注意

    - -
      -
    • 从Gecko 27 {{geckoRelease(27)}}开始,此方法遵守ECMAScript 规范。当使用全局正则表达式调用 match()时,{{jsxref("RegExp.lastIndex")}} 属性(如果指定)会重置为 0 ({{bug(501739)}})。
    • -
    • 从 Gecko 39 {{geckoRelease(39)}}开始,不赞成使用非标准的标志参数,并抛出一个控制台警告({{bug(1142351)}})。
    • -
    • 从 Gecko 47 {{geckoRelease(47)}} 开始 , non-release builds不再支持非标准的标志参数,并且将完全移除({{bug(1245801)}})。
    • -
    • 从 Gecko 49 {{geckoRelease(49)}} 开始 , 不再支持非标准的标志参数 ({{bug(1108382)}}).
    • -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/matchall/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/matchall/index.html index d11d23265e..662d4ff564 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/matchall/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/matchall/index.html @@ -24,9 +24,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/matchAll

    参数

    -
    -
    regexp
    -
    +

    regexp

        正则表达式对象。如果所传参数不是一个正则表达式对象,则会隐式地使用 new RegExp(obj) 将其转换为一个 RegExp 。

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.html index c358da2585..1d1a9c1176 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/padstart/index.html @@ -35,7 +35,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/padStart

    示例

    -
    'abc'.padStart(10);         // "       abc"
    +
    'abc'.padStart(10);         // "       abc"
     'abc'.padStart(10, "foo");  // "foofoofabc"
     'abc'.padStart(6,"123465"); // "123abc"
     'abc'.padStart(8, "0");     // "00000abc"
    @@ -45,7 +45,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/padStart
     
     

    如果原生环境不支持该方法,在其他代码之前先运行下面的代码,将创建 String.prototype.padStart() 方法。

    -
    // https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
    +
    // https://github.com/uxitten/polyfill/blob/master/string.polyfill.js
     // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart
     if (!String.prototype.padStart) {
         String.prototype.padStart = function padStart(targetLength,padString) {
    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 45ea5be584..c63c2144f4 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
    @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/repeat
     
     

    此方法已添加到 ECMAScript 2015 规范中,并且可能尚未在所有 JavaScript 实现中可用。然而,你可以使用以下代码段对 String.prototype.repeat() 进行填充:

    -
    if (!String.prototype.repeat) {
    +
    if (!String.prototype.repeat) {
       String.prototype.repeat = function(count) {
         'use strict';
         if (this == null) {
    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 3bc425e928..66226c970e 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
    @@ -53,8 +53,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replace
     
    -   
    -   
    +   
    +   
    @@ -94,8 +94,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replace
     
    变量名代表的值变量名代表的值
    $$
    - - + + diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/replaceall/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/replaceall/index.html index c9d892e3f7..726bfe2530 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/replaceall/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/replaceall/index.html @@ -21,8 +21,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replaceAll
    const newStr = str.replaceAll(regexp|substr, newSubstr|function)
    -
    -

    当使用一个 `regex`时,您必须设置全局(“ g”)标志,
    +

    +

    备注:当使用一个 `regex`时,您必须设置全局(“ g”)标志,
    否则,它将引发 TypeError:“必须使用全局 RegExp 调用 replaceAll”。

    @@ -54,8 +54,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replaceAll
    变量名代表的值变量名代表的值
    match
    - - + + @@ -93,8 +93,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replaceAll
    PatternInsertsPatternInserts
    - - + + diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/small/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/small/index.html index 834ceed5ac..72b59b6142 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/small/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/small/index.html @@ -61,55 +61,7 @@ console.log(worldString.fontsize(7)); // <font size="7">Hello, world</f

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    -
    Possible nameSupplied valuePossible nameSupplied value
    - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    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 75ba2c0748..e6eb4945f6 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 @@ -23,8 +23,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/split
    str.split([separator[, limit]])
     
    -
    -

    注意:如果使用空字符串(“)作为分隔符,则字符串不是在每个用户感知的字符(图形素集群)之间,也不是在每个Unicode字符(代码点)之间,而是在每个UTF-16代码单元之间。这会摧毁代理对。还请参见how do you get a string to a character array in javascript

    +
    +

    警告:如果使用空字符串(“)作为分隔符,则字符串不是在每个用户感知的字符(图形素集群)之间,也不是在每个Unicode字符(代码点)之间,而是在每个UTF-16代码单元之间。这会摧毁代理对。还请参见how do you get a string to a character array in javascript

    参数

    @@ -155,8 +155,8 @@ console.log(splits); //["c", "c,", "c", "c", "c"]

    用split()来颠倒字符串顺序

    -
    -

    注意这并非一种很健壮的逆转字符串的方法:

    +
    +

    警告:注意这并非一种很健壮的逆转字符串的方法:

    const str = 'asdfghjkl';
     const strReverse = str.split('').reverse().join(''); // 'lkjhgfdsa'
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/strike/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/strike/index.html
    index 12304c18cf..3bea6eba71 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/string/strike/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/string/strike/index.html
    @@ -57,55 +57,7 @@ console.log(worldString.strike()); // <strike>Hello, world</strike>
     
     

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/sub/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/sub/index.html index 69402cb285..6662e050e4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/sub/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/sub/index.html @@ -62,55 +62,7 @@ console.log('This is what a ' + subText.sub() + ' looks like.');

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    另见

    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 5c94a75240..4916b09abe 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 @@ -7,7 +7,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/substr ---

    {{JSRef}}

    -
    警告: 尽管 String.prototype.substr(…) 没有严格被废弃 (as in "removed from the Web standards"), 但它被认作是遗留的函数并且可以的话应该避免使用。它并非JavaScript核心语言的一部分,未来将可能会被移除掉。如果可以的话,使用 substring() 替代它.
    +

    警告:尽管 String.prototype.substr(…) 没有严格被废弃 (as in "removed from the Web standards"), 但它被认作是遗留的函数并且可以的话应该避免使用。它并非JavaScript核心语言的一部分,未来将可能会被移除掉。如果可以的话,使用 substring() 替代它.

    substr() 方法返回一个字符串中从指定位置开始到指定字符数的字符。

    @@ -103,57 +103,7 @@ if ('ab'.substr(-1) != 'b')

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -

    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.

    +{{Compat}}

    相关链接

    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 6aef7ea138..bf4162a1c3 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 @@ -136,55 +136,7 @@ replaceString("World", "Web", "Brave New World");

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/sup/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/sup/index.html index 15616dfc08..0027d16fd0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/sup/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/sup/index.html @@ -61,55 +61,7 @@ console.log('This is what a ' + subText.sub() + ' looks like.');

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/tolocalelowercase/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/tolocalelowercase/index.html index c4f1025029..e3675a0195 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/tolocalelowercase/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/tolocalelowercase/index.html @@ -86,55 +86,7 @@ let locales = ['tr', 'TR', 'tr-TR', 'tr-u-co-search', 'tr-x-turkish'];

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    参阅

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html index e8fd231457..f492176f46 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/tolowercase/index.html @@ -15,7 +15,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/toLowerCase

    语法

    -
    str.toLowerCase()
    +
    str.toLowerCase()
     

    返回值

    @@ -36,8 +36,6 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/toLowerCase ​console.log( "ALPHABET".toLowerCase() ); // "alphabet"
    -
    -

    说明

    @@ -75,55 +73,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/toLowerCase

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/tosource/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/tosource/index.html index 756758d877..1b6c4f7a85 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/string/tosource/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/string/tosource/index.html @@ -32,57 +32,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/toSource

    不属于任何标准. 在 JavaScript 1.3实现了.

    -

    浏览器适配

    +

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    参见

    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 ff09cb22b0..98d7890b15 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 @@ -66,55 +66,7 @@ alert(x.toString()) // 输出 "Hello world"

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    +{{Compat}}

    相关链接

    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 1edf0d9200..59e70e782b 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 @@ -43,7 +43,7 @@ original_slug: Web/JavaScript/Reference/Global_Objects/String/TrimRight

    下面的例子输出了小写的字符串"   foo":

    -
    var str = "   foo  ";
    +
    var str = "   foo  ";
     
     alert(str.length); // 8
     
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/string/trimstart/index.html b/files/zh-cn/web/javascript/reference/global_objects/string/trimstart/index.html
    index 48718fcb13..655126befb 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/string/trimstart/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/string/trimstart/index.html
    @@ -45,7 +45,7 @@ original_slug: Web/JavaScript/Reference/Global_Objects/String/TrimLeft
     
     

    下面的例子输出了小写的字符串 "foo  "

    -
    var str = "   foo  ";
    +
    var str = "   foo  ";
     
     console.log(str.length); // 8
     
    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 2b5df3a89c..ebb9e724e9 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
    @@ -97,55 +97,7 @@ Symbol.for("mdn.bar");
     
     

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatChrome(40) }}{{ CompatGeckoDesktop("36.0") }}{{ CompatNo() }}{{ CompatNo() }}10
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatGeckoMobile("36.0") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
    -
    +{{Compat}}

    相关链接

    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 a0165478d4..2448eb3d7f 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 @@ -77,13 +77,13 @@ typeof symObj; // "object"
    -

    迭代 symbols {{jsxref("Symbol.iterator")}}

    + 迭代 symbols {{jsxref("Symbol.iterator")}}
    一个返回一个对象默认迭代器的方法。被 for...of 使用。
    {{jsxref("Symbol.asyncIterator")}} {{experimental_inline}}
    一个返回对象默认的异步迭代器的方法。被 for await of 使用。
    -

    正则表达式 symbols {{jsxref("Symbol.match")}}

    + 正则表达式 symbols {{jsxref("Symbol.match")}}
    一个用于对字符串进行匹配的方法,也用于确定一个对象是否可以作为正则表达式使用。被 {{jsxref("String.prototype.match()")}} 使用。
    {{jsxref("Symbol.replace")}}
    @@ -93,7 +93,7 @@ typeof symObj; // "object"
    {{jsxref("Symbol.split")}}
    一个在匹配正则表达式的索引处拆分一个字符串的方法.。被 {{jsxref("String.prototype.split()")}} 使用。
    -

    其他 symbols {{jsxref("Symbol.hasInstance")}}

    + 其他 symbols {{jsxref("Symbol.hasInstance")}}
    一个确定一个构造器对象识别的对象是否为它的实例的方法。被 {{jsxref("Operators/instanceof", "instanceof")}} 使用。
    {{jsxref("Symbol.isConcatSpreadable")}}
    @@ -167,7 +167,7 @@ typeof Symbol.iterator === 'symbol'

    Symbols 在 for...in 迭代中不可枚举。另外,{{jsxref("Object.getOwnPropertyNames()")}} 不会返回 symbol 对象的属性,但是你能使用 {{jsxref("Object.getOwnPropertySymbols()")}} 得到它们。

    -
    var obj = {};
    +
    var obj = {};
     
     obj[Symbol("a")] = "a";
     obj[Symbol.for("b")] = "b";
    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 9877b68ce0..76daeafd72 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
    @@ -22,9 +22,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/keyFor
     
     

    返回值

    -
    -
    如果全局注册表中查找到该symbol,则返回该symbol的key值,返回值为字符串类型。否则返回undefined
    -
    +

    如果全局注册表中查找到该symbol,则返回该symbol的key值,返回值为字符串类型。否则返回undefined

    示例

    @@ -58,55 +56,7 @@ Symbol.keyFor(Symbol.iterator) // undefined

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatNo() }}{{ CompatGeckoDesktop("33.0") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatNo() }}{{ CompatNo() }}{{ CompatGeckoMobile("33.0") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/search/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/search/index.html index 7f3ac000d6..f37ad018db 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/search/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/search/index.html @@ -53,55 +53,7 @@ console.log('foobar'.search(new caseInsensitiveSearch('BaR')));

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支持{{CompatChrome(50)}}{{ CompatGeckoDesktop(49) }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基本支持{{CompatNo}}{{CompatNo}}{{ CompatGeckoMobile(49) }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    参见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html index 220716da29..ce514451d9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/split/index.html @@ -55,55 +55,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Symbol/split

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(50)}}{{ CompatGeckoDesktop(49) }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{ CompatGeckoMobile(49) }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    参阅

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/toprimitive/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/toprimitive/index.html index bbf27b98d6..18c1c5a6e9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/toprimitive/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/toprimitive/index.html @@ -68,14 +68,7 @@ console.log(obj2 + ""); // "true" -- hint 参数值是 "default"

    浏览器兼容性

    -

     {{Compat("javascript.builtins.Symbol.toPrimitive")}}

    - -
    - - - -
    -
    +{{Compat}}

    其他资料

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/tosource/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/tosource/index.html index 6342361cc9..87d28009f3 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/tosource/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/tosource/index.html @@ -34,57 +34,9 @@ sym.toSource()

    还未成为任何标准的一部分

    -

    Browser compatibility

    - -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatNo}}{{ CompatGeckoDesktop("36.0") }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{ CompatGeckoMobile("36.0") }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +

    浏览器兼容性

    + +{{Compat}}

    See also

    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 d59863f878..88ae116c0f 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 @@ -59,55 +59,7 @@ Symbol.for("foo").toString() // "Symbol(foo)"

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatGeckoDesktop("33.0") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatGeckoMobile("33.0") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/symbol/tostringtag/index.html b/files/zh-cn/web/javascript/reference/global_objects/symbol/tostringtag/index.html index 82f699b536..27f3bf4402 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/symbol/tostringtag/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/symbol/tostringtag/index.html @@ -72,55 +72,7 @@ Object.prototype.toString.call(new ValidatorClass()); // "[object Validator]"

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(49)}}{{CompatGeckoDesktop(51)}}{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(51)}}{{CompatNo}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    相关链接

    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 c9e9c55adb..e4a00990ca 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 @@ -49,55 +49,7 @@ Object(Symbol("foo")).toString() + "bar";

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatGeckoDesktop("33.0") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatGeckoMobile("33.0") }}{{ CompatNo() }}{{ CompatNo() }}{{ CompatNo() }}
    -
    +{{Compat}}

    相关链接

    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 6c75432980..2171da8054 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 @@ -113,55 +113,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/SyntaxError

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/@@iterator/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/@@iterator/index.html index 3704f46a52..eb8c8b2c1a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/@@iterator/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/@@iterator/index.html @@ -62,55 +62,7 @@ console.log(eArr.next().value); // 50

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown }}{{ CompatGeckoDesktop("36") }} [1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{ CompatVersionUnknown }}{{ CompatGeckoMobile("36") }} [1]{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    [1] 从 Gecko 17 (Firefox 17 / Thunderbird 17 / SeaMonkey 2.14) 到 Gecko 26 (Firefox 26 / Thunderbird 26 / SeaMonkey 2.23 / Firefox OS 1.2) 使用 iterator 属性 (bug 907077),从 Gecko 27 到 Gecko 35 使用"@@iterator" 占位符。 在 Gecko 36 (Firefox 36 / Thunderbird 36 / SeaMonkey 2.33)中,@@iterator Symbol 予以实现(bug 918828)。

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/@@species/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/@@species/index.html index b4766bd8f3..181102baae 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/@@species/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/@@species/index.html @@ -68,55 +68,7 @@ Float32Array[Symbol.species]; // function Float32Array()

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatUnknown}}{{CompatGeckoDesktop("48")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("48")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/buffer/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/buffer/index.html index 93ffe360f2..e59f0d2a71 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/buffer/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/buffer/index.html @@ -48,55 +48,7 @@ uint16.buffer; // ArrayBuffer { byteLength: 8 }

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support7.0{{ CompatGeckoDesktop("2") }}1011.65.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support4.0{{CompatVersionUnknown}}{{ CompatGeckoMobile("2") }}1011.64.2
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/bytelength/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/bytelength/index.html index 8de0fa848f..50805ed8c1 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/bytelength/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/bytelength/index.html @@ -55,55 +55,7 @@ uint8.byteLength; // 6 (根据被构造的 Uint8Array 的 offset)

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support7.0{{ CompatGeckoDesktop("2") }}1011.65.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support4.0{{CompatVersionUnknown}}{{CompatGeckoMobile("2")}}1011.64.2
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/byteoffset/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/byteoffset/index.html index 4c99e61454..9561697042 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/byteoffset/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/byteoffset/index.html @@ -52,55 +52,7 @@ uint8.byteOffset; // 3 (在构造 Uint8Array 时指定)

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support7.0{{ CompatGeckoDesktop("2") }}1011.65.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support4.0{{CompatVersionUnknown}}{{ CompatGeckoMobile("2") }}1011.64.2
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/bytes_per_element/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/bytes_per_element/index.html index ce51212c7a..de2a646149 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/bytes_per_element/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/bytes_per_element/index.html @@ -55,57 +55,7 @@ Float64Array.BYTES_PER_ELEMENT; // 8

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    - - - - - - - - - - - - - - - - - - - -
    功能ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支持7.0{{ CompatGeckoDesktop("2") }}1011.65.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    功能AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基本支持4.0{{ CompatVersionUnknown() }}{{ CompatGeckoMobile("2") }}1011.64.2
    -
    - -

     

    +{{Compat}}

    参见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/copywithin/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/copywithin/index.html index ed9dd53aab..d15c54bd61 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/copywithin/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/copywithin/index.html @@ -69,57 +69,7 @@ console.log(uint8); // Uint8Array [ 1, 2, 3, 1, 2, 3, 0, 0 ]

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(45.0)}}{{CompatGeckoDesktop("34")}}{{CompatNo}} -

     {{CompatOpera(36.0)}}

    -
    {{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("34")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/entries/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/entries/index.html index 606e75883c..e9e9244dc0 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/entries/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/entries/index.html @@ -63,55 +63,7 @@ console.log(eArr.next().value); // [4, 50]

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(45.0)}}{{CompatGeckoDesktop(37)}}{{CompatNo}}{{CompatOpera(36.0)}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{ CompatVersionUnknown }}{{CompatGeckoMobile(37)}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/every/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/every/index.html index f38c199989..073c3d49a4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/every/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/every/index.html @@ -49,7 +49,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypedArray/every

    下面的示例测试了类型化数组所有元素是否大于 10。

    -
    function isBigEnough(element, index, array) {
    +
    function isBigEnough(element, index, array) {
       return element >= 10;
     }
     new Uint8Array([12, 5, 8, 130, 44]).every(isBigEnough);   // false
    @@ -86,55 +86,7 @@ new Uint8Array([12, 54, 18, 130, 44]).every(elem => elem >= 10); // true浏览器兼容性
     
    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(45.0)}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatOpera(36.0)}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/fill/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/fill/index.html index ab7506d843..4aa5a96487 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/fill/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/fill/index.html @@ -77,55 +77,7 @@ if (!Uint8Array.prototype.fill) {

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基础支持45{{CompatGeckoDesktop("37")}}{{CompatNo}}32{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    特性AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基础支持{{CompatNo}}{{CompatNo}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/filter/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/filter/index.html index c5d87874b3..1685bdb678 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/filter/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/filter/index.html @@ -86,55 +86,7 @@ new Uint8Array([12, 5, 8, 130, 44]).filter(isBigEnough);

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("45")}}{{CompatGeckoDesktop("38")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("38")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/find/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/find/index.html index 8482375404..409455ce73 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/find/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/find/index.html @@ -90,55 +90,7 @@ console.log(uint8.find(isPrime)); // 5

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatNo}}{{CompatGeckoDesktop("37.0")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("37.0")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/findindex/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/findindex/index.html index 938419d229..adc1ec6cbf 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/findindex/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/findindex/index.html @@ -130,55 +130,7 @@ console.log(uint16.findIndex(isPrime)); // 2

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatNo}}{{CompatGeckoDesktop("37.0")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("37.0")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/foreach/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/foreach/index.html index b88d1af965..5d6e3ed39d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/foreach/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/foreach/index.html @@ -93,13 +93,7 @@ new Uint8Array([0, 1, 2, 3]).forEach(logArrayElements);

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - -

    {{Compat("javascript.builtins.TypedArray.forEach")}}

    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/from/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/from/index.html index 20bdbf8b7f..6e480125ab 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/from/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/from/index.html @@ -8,7 +8,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypedArray/from ---
    {{JSRef}}
    -

    TypedArray.from() 方法 从一个类数组或者可迭代对象中创建一个新类型数组。 这个方法和 {{jsxref("Array.from()")}} 类似。

    +

    TypedArray.from() 方法 从一个类数组或者可迭代对象中创建一个新类型数组。 这个方法和 {{jsxref("Array.from()")}} 类似。

    语法

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/includes/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/includes/index.html index efa225622f..44610ac2c2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/includes/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/includes/index.html @@ -61,57 +61,7 @@ new Float64Array([NaN]).includes(NaN); // true;

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)EdgeInternet ExplorerOperaSafari
    Basic support474314{{CompatNo}}3410
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}4743{{CompatNo}}3410
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/indexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/indexof/index.html index 24d78f6487..6c99a285b4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/indexof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/indexof/index.html @@ -65,57 +65,7 @@ uint8.indexOf(2, -3); // 0

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("45")}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatChrome("32")}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    兼容性注解

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/join/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/join/index.html index 3d41de4353..f23465e341 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/join/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/join/index.html @@ -68,57 +68,7 @@ if (!Uint8Array.prototype.join) {

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("37")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/keys/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/keys/index.html index 4b10667f83..cd35ea4882 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/keys/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/keys/index.html @@ -63,57 +63,7 @@ console.log(eArr.next().value); // 4

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop(37)}}{{CompatNo}}{{CompatNo}}10
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatVersionUnknown}}{{CompatGeckoMobile(37)}}{{CompatNo}}{{CompatNo}}10
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/lastindexof/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/lastindexof/index.html index 16be84ff24..0b93a012c2 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/lastindexof/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/lastindexof/index.html @@ -63,57 +63,7 @@ uint8.lastIndexOf(2, -1); // 3

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatVersionUnknown}}10
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatNo}}10
    -
    +{{Compat}}

    兼容性注解

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/length/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/length/index.html index 797f2ea5cb..ae62853450 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/length/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/length/index.html @@ -55,55 +55,7 @@ uint8.length; // 6 (根据被构造的 Uint8Array 的 offset)

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support7.0{{CompatGeckoDesktop("2")}}1011.65.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support4.0{{CompatVersionUnknown}}{{CompatGeckoMobile("2")}}1011.64.2
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/map/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/map/index.html index 959930fbda..644720ff35 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/map/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/map/index.html @@ -93,55 +93,7 @@ var doubles = numbers.map(function(num) {

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop("38")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("38")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/name/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/name/index.html index cfe0be7792..e9572fa1af 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/name/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/name/index.html @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypedArray/name ---
    {{JSRef}}
    -

    TypedArray.name ?属性是描述类型数组构造名的字符串值。

    +

    TypedArray.name ?属性是描述类型数组构造名的字符串值。

    {{js_property_attributes(0,0,0)}}
    @@ -57,57 +57,9 @@ Float64Array.name; // "Float64Array"
    -

    ?浏览器兼容

    +

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    ?特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    ?基础支持7.0{{ CompatGeckoDesktop("2") }}1011.65.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    特性AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基础支持4.0{{CompatVersionUnknown}}{{CompatGeckoMobile("2")}}1011.64.2
    -
    +{{Compat}}

    参见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/of/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/of/index.html index 831a2a0b84..235c64ade4 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/of/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/of/index.html @@ -10,7 +10,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypedArray/of ---
    {{JSRef}}
    -

    TypedArray.of() 方法创建一个具有可变数量参数的新类型数组 。此方法几乎与{{jsxref("Array.of()")}} 相同。

    +

    TypedArray.of() 方法创建一个具有可变数量参数的新类型数组 。此方法几乎与{{jsxref("Array.of()")}} 相同。

    句法

    @@ -80,55 +80,7 @@ Int16Array.of(undefined); // IntArray [ 0 ]

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(45.0)}}{{CompatGeckoDesktop("38")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("38")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    也可以看看

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/reduce/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/reduce/index.html index 929e05ba86..7f78fcc652 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/reduce/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/reduce/index.html @@ -77,57 +77,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypedArray/reduce

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("47")}}12{{CompatGeckoDesktop("37")}}{{CompatUnknown}}{{CompatOpera("32")}}{{CompatSafari("10")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("37")}}{{CompatUnknown}}{{CompatUnknown}}10
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/reduceright/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/reduceright/index.html index 172c9706f7..c1e610466c 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/reduceright/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/reduceright/index.html @@ -84,57 +84,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypedArray/reduceRight

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("45")}}12{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatOpera("32")}}{{CompatSafari("10")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("37")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/reverse/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/reverse/index.html index 9011f29dac..c9657489ee 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/reverse/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/reverse/index.html @@ -47,57 +47,7 @@ console.log(uint8); // Uint8Array [3, 2, 1]

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("45")}}12{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatOpera("32")}}{{CompatSafari("10")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatGeckoDesktop("37")}}{{CompatNo}}{{CompatNo}}10
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/set/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/set/index.html index bced96b90f..b8918fa5bb 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/set/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/set/index.html @@ -71,55 +71,7 @@ console.log(uint8); // Uint8Array [ 0, 0, 0, 1, 2, 3, 0, 0 ]

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    浏览器ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    最低版本7.0{{CompatGeckoDesktop("2")}}1011.65.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    浏览器AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    最低版本4.0{{CompatVersionUnknown}}{{CompatGeckoMobile("2")}}1011.64.2
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/some/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/some/index.html index 4c285a5fe1..28bb353173 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/some/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/some/index.html @@ -55,7 +55,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/TypedArray/some

    以下示例测试typed array中的所有元素都大于10.

    -
    function isBiggerThan10(element, index, array) {
    +
    function isBiggerThan10(element, index, array) {
       return element > 10;
     }
     new Uint8Array([2, 5, 8, 1, 4]).some(isBiggerThan10); // false
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/sort/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/sort/index.html
    index 14bb6c17dc..68b221ec1d 100644
    --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/sort/index.html
    +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/sort/index.html
    @@ -69,55 +69,7 @@ numbers.sort(compareNumbers);
     
     

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop(46)}}{{CompatUnknown}}{{CompatVersionUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(46)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/tostring/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/tostring/index.html index b5417f1a27..eeb8296eb7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/tostring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/tostring/index.html @@ -57,55 +57,7 @@ numbers.toString(); // "[object Uint8Array]"

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatGeckoDesktop(51)}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile(51)}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/typedarray/values/index.html b/files/zh-cn/web/javascript/reference/global_objects/typedarray/values/index.html index 3b88e98f0b..1137bf72a7 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/typedarray/values/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/typedarray/values/index.html @@ -63,57 +63,7 @@ console.log(eArr.next().value); // 50

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown }}12{{CompatGeckoDesktop(37)}}{{CompatNo}}{{CompatOpera("26")}}{{CompatSafari("10")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{ CompatVersionUnknown }}{{CompatGeckoMobile(37)}}{{CompatNo}}{{CompatNo}}10
    -
    +{{Compat}}

    另见

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/uint8clampedarray/index.html b/files/zh-cn/web/javascript/reference/global_objects/uint8clampedarray/index.html index f1fe65cc75..0863a75053 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/uint8clampedarray/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/uint8clampedarray/index.html @@ -177,89 +177,7 @@ var uintc8 = new Uint8ClampedArray(iterable);

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    特性ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基础支持7.0{{ CompatGeckoDesktop(2) }}11 (as of KB2929437)11.65.1
    需要使用 new{{CompatUnknown}}{{ CompatGeckoDesktop(44) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    构造函数中可枚举{{CompatUnknown}}{{ CompatGeckoDesktop(52) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    特性AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基础支持4.0{{CompatVersionUnknown}}{{ CompatGeckoMobile(2) }}{{CompatVersionUnknown}}11.64.2
    需要使用 new{{CompatUnknown}}{{CompatUnknown}}{{ CompatGeckoMobile(44) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    构造函数中可枚举{{CompatUnknown}}{{CompatUnknown}}{{ CompatGeckoMobile(52) }}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    兼容性注意事项

    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 e440e136f6..9e2241c565 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 @@ -43,7 +43,7 @@ test(); // 返回"undefined"

    一个函数如果没有使用return语句指定{{jsxref("Statements/return", "返回")}}值,就会返回一个undefined值。

    -

    但是它有可能在非全局作用域中被当作{{Glossary("Identifier", "标识符")}}(变量名)来使用(因为undefined不是一个{{jsxref("Reserved_Words", "保留字")}})),这样做是一个非常坏的主意,因为这样会使你的代码难以去维护和排错。

    +

    警告:但是它有可能在非全局作用域中被当作{{Glossary("Identifier", "标识符")}}(变量名)来使用(因为undefined不是一个{{jsxref("Reserved_Words", "保留字")}})),这样做是一个非常坏的主意,因为这样会使你的代码难以去维护和排错。

    // 不要这样做!
     
    @@ -76,7 +76,7 @@ if (x === undefined) {
     }
    -

    注意:这里是必须使用严格相等操作符(===)而不是标准相等操作符(==),因为 x == undefined 会检查x是不是null,但是严格相等不会检查(有点饶人,其实 === 会严格判断双方的类型、值等是否相等)。null不等同于undefined。移步{{jsxref("Operators/Comparison_Operators", "比较操作符")}}查看详情。

    +

    备注:这里是必须使用严格相等操作符(===)而不是标准相等操作符(==),因为 x == undefined 会检查x是不是null,但是严格相等不会检查(有点饶人,其实 === 会严格判断双方的类型、值等是否相等)。null不等同于undefined。移步{{jsxref("Operators/Comparison_Operators", "比较操作符")}}查看详情。

    Typeof 操作符和undefined

    @@ -101,7 +101,7 @@ if(y === undefined) { // ReferenceError: y is not defined

    但是,技术方面看来这样的使用方法应该被避免。JavaScript是一个静态作用域语言,所以,一个变量是否被声明可以通过看它是否在一个封闭的上下文中被声明。唯一的例外是全局作用域,但是全局作用域是被绑定在全局对象上的,所以要检查一个变量是否在全局上下文中存在可以通过检查全局对象上是否存在这个属性(比如使用{{jsxref("Operators/in", "in")}}操作符)。

    -
    if ('x' in window) {
    +
    if ('x' in window) {
       // 只有x被全局性的定义 才会这行这些语句
     }
    diff --git a/files/zh-cn/web/javascript/reference/global_objects/unescape/index.html b/files/zh-cn/web/javascript/reference/global_objects/unescape/index.html index 85746f1bc3..36699ebc8f 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/unescape/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/unescape/index.html @@ -9,7 +9,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/unescape

    已废弃的unescape() 方法计算生成一个新的字符串,其中的十六进制转义序列将被其表示的字符替换。上述的转义序列就像{{jsxref("escape")}}里介绍的一样。因为 unescape 已经废弃,建议使用 {{jsxref("decodeURI")}}或者{{jsxref("decodeURIComponent")}} 替代本方法。

    -
    注意:不要使用unescape去解码URLS,使用decodeURIdecodeURIComponent替代。
    +
    +

    备注:不要使用unescape去解码URLS,使用decodeURIdecodeURIComponent替代。

    +

    语法

    @@ -20,12 +22,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/unescape
    str
    被编码过的字符串。
    -
    -

    返回值

    -
    -
    一个未被转义的新字符串。
    +

    返回值

    + +

    一个未被转义的新字符串。

    +

    描述

    unescape函数是全局对象的一个属性。

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/uneval/index.html b/files/zh-cn/web/javascript/reference/global_objects/uneval/index.html index 234b683d48..f0a0119d4d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/uneval/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/uneval/index.html @@ -22,11 +22,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/uneval

    返回值

    -
    -
    表示给定对象的源代码的字符串
    -
    +

    表示给定对象的源代码的字符串

    -
    注意:无法通过此方法获取对象的 JSON 形式。
    +
    +

    备注:无法通过此方法获取对象的 JSON 形式。

    +

    描述

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakmap/clear/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakmap/clear/index.html index 5340ac3ee0..5344e4f3a6 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakmap/clear/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/weakmap/clear/index.html @@ -13,9 +13,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/clear

    clear()用来从 WeakMap对象中移除所有元素。但不再是ECMAScript和它的实现部分。

    -

    Warning:

    +

    警告:Warning:

    -

    WeakMap(no clear() any more).png

    +

    WeakMap(no clear() any more).png

    语法

    @@ -26,7 +26,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WeakMap/clear

    使用 clear 方法

    -
    var wm = new WeakMap();
    +
    var wm = new WeakMap();
     var obj = {};
     
     wm.set(obj, "foo");
    @@ -47,55 +47,7 @@ wm.has(window)  // false
     
     

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support36{{CompatNo}} [1]11237.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}} [1]{{CompatNo}}{{CompatNo}}8
    -
    - -

    [1] The clear() 曾经在高于 20 版本低于 45 版本之间被支持。

    +{{Compat}}

    相近

    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 212911cf30..f1dd0b2ddd 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 @@ -53,53 +53,7 @@ wm.has(window); // 返回 false,因为 window 对象已经被删除了。

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (SpiderMonkey)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}[1]{{CompatGeckoDesktop("6.0")}}11{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidFirefox Mobile (SpiderMonkey)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatGeckoMobile("6.0")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakmap/get/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakmap/get/index.html index 1c335a5ffc..26598a6cdf 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakmap/get/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/weakmap/get/index.html @@ -57,53 +57,7 @@ wm.get("baz"); // 返回 undefined.

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support36{{CompatGeckoDesktop("6.0")}}11237.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatGeckoMobile("6.0")}}{{CompatNo}}{{CompatNo}}8
    -
    +{{Compat}}

    Firefox 中的注意事项

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html index 209fd757d0..80e653a911 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/weakmap/has/index.html @@ -58,55 +58,9 @@ wm.has("baz"); // returns false -

    浏览器兼容

    +

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support36{{CompatGeckoDesktop("6.0")}}11237.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatGeckoMobile("6.0")}}{{CompatNo}}{{CompatNo}}8
    -
    +{{Compat}}

    Firefox-特有说明

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakref/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakref/index.html index 9f9f275816..ec593be548 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakref/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/weakref/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WeakRef

    WeakRef对象包含对对象的弱引用,这个弱引用被称为该WeakRef对象的target或者是referent。对对象的弱引用是指当该对象应该被GC回收时不会阻止GC的回收行为。而与此相反的,一个普通的引用(默认是强引用)会将与之对应的对象保存在内存中。只有当该对象没有任何的强引用时,JavaScript引擎GC才会销毁该对象并且回收该对象所占的内存空间。如果上述情况发生了,那么你就无法通过任何的弱引用来获取该对象。

    -

    Note: 在使用前请阅读Avoid where possible,对于WeakRef对象的使用要慎重考虑,能不使用就尽量不要使用

    +

    备注: 在使用前请阅读Avoid where possible,对于WeakRef对象的使用要慎重考虑,能不使用就尽量不要使用

    构造函数

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakset/add/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakset/add/index.html index 01209019ba..d57c1762e9 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakset/add/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/weakset/add/index.html @@ -64,53 +64,7 @@ ws.add(1);

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support36{{CompatGeckoDesktop(34)}}{{CompatNo}}23{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{ CompatGeckoMobile(34) }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakset/delete/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakset/delete/index.html index b7f9c4f1b2..bd4bb8e950 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakset/delete/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/weakset/delete/index.html @@ -61,53 +61,7 @@ ws.has(window); // 返回 false。因为 WeakSet 中已经不存在 window

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support36{{CompatGeckoDesktop(34)}}{{CompatNo}}23{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{ CompatGeckoMobile(34) }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakset/has/index.html b/files/zh-cn/web/javascript/reference/global_objects/weakset/has/index.html index 60a33bf90e..896b71ccec 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakset/has/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/weakset/has/index.html @@ -61,53 +61,7 @@ mySet.has(obj); // 返回 false

    浏览器兼容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support36{{CompatGeckoDesktop(34)}}{{CompatNo}}23{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{ CompatGeckoMobile(34) }}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    相关链接

    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 c87d989111..4d6b153d0a 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 @@ -67,7 +67,7 @@ WebAssembly.instantiateStreaming(fetch('global.wasm'), { js: { global } }) });
    -

    注意: 你可以在running live on GitHub 查看例子; 也可以访问source code.

    +

    备注:: 你可以在running live on GitHub 查看例子; 也可以访问source code.

    规格

    @@ -89,13 +89,9 @@ WebAssembly.instantiateStreaming(fetch('global.wasm'), { js: { global } }) -

    浏览器兼容性

    -
    - - -

    {{Compat("javascript.builtins.WebAssembly.Global")}}

    -
    +{{Compat}}

    See also

    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 d4b5877590..f2637be5b6 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 @@ -63,7 +63,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly

    下面的示例(请参见GitHub上的Instantiate-streaming.html演示,并查看在线演示)直接从流式底层源传输.wasm模块,然后对其进行编译和实例化,并通过ResultObject实现promise。 由于instantiateStreaming()函数接受对 {{domxref("Response")}} 对象的promise,因此您可以直接向其传递{{domxref("WindowOrWorkerGlobalScope.fetch()")}}调用,然后它将把返回的response传递给随后的函数。

    -
    var importObject = { imports: { imported_func: arg => console.log(arg) } };
    +
    var importObject = { imports: { imported_func: arg => console.log(arg) } };
     
     WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject)
     .then(obj => obj.instance.exports.exported_func())
    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 e64f663b93..d66e1554ca 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 @@ -18,7 +18,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance

    构造函数

    -

    重要: 由于大型模块的实例化代价极高, 开发人员应只在必须同步实例化的时候,才使用Instance();绝大多数情况应该使用异步方法{{jsxref("WebAssembly.instantiate()")}} .

    +

    警告:由于大型模块的实例化代价极高, 开发人员应只在必须同步实例化的时候,才使用Instance();绝大多数情况应该使用异步方法{{jsxref("WebAssembly.instantiate()")}} .

    var myInstance = new WebAssembly.Instance(module, importObject);
    @@ -41,7 +41,6 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance
    {{jsxref("WebAssembly/Instance/exports", "Instance.prototype.exports")}}
    返回一个包含此 WebAssembly 模块实例所导出的全部成员的 JS 对象,以便 JavaScript 访问和使用这些成员,这个对象是只读的。
    -

    规格

    @@ -63,9 +62,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance -

    浏览器兼容性

    -
    {{Compat("javascript.builtins.WebAssembly.Instance")}}
    +{{Compat}}

    参考

    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 43b3aad734..9d0d988668 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 @@ -12,8 +12,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/instantiate
  • 第二种重载使用已编译的 {{jsxref("WebAssembly.Module")}} , 返回的 Promise 携带一个 Module的实例化对象 Instance. 如果这个 Module 已经被编译了或者是从缓存中获取的( retrieved from cache), 那么这种重载方式是非常有用的.
  • -
    -

    重要: 此方法不是获取(fetch)和实例化wasm模块的最具效率方法。 如果可能的话,您应该改用较新的{{jsxref("WebAssembly.instantiateStreaming()")}}方法,该方法直接从原始字节码中直接获取,编译和实例化模块,因此不需要转换为{{jsxref("ArrayBuffer")}}。

    +
    +

    警告:此方法不是获取(fetch)和实例化wasm模块的最具效率方法。 如果可能的话,您应该改用较新的{{jsxref("WebAssembly.instantiateStreaming()")}}方法,该方法直接从原始字节码中直接获取,编译和实例化模块,因此不需要转换为{{jsxref("ArrayBuffer")}}。

    语法

    @@ -103,7 +103,7 @@ fetch('simple.wasm').then(response => );
    -

    : 查看GitHub(在线实例)的 index.html 中一个相似的例子,使用了我们的fetchAndInstantiate()库函数

    +

    备注:: 查看GitHub(在线实例)的 index.html 中一个相似的例子,使用了我们的fetchAndInstantiate()库函数

    第二种重载例子

    @@ -158,13 +158,9 @@ onmessage = function(e) { -

    浏览器兼容性

    -
    - - -

    {{Compat("javascript.builtins.WebAssembly.instantiate")}}

    -
    +{{Compat}}

    参见

    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 15af74d96b..9283dfc9c2 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,13 +66,9 @@ WebAssembly.instantiateStreaming(fetch('simple.wasm'), importObject) -

    浏览器兼容性

    -
    - - -

    {{Compat("javascript.builtins.WebAssembly.instantiateStreaming")}}

    -
    +{{Compat}}

    See also

    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 f8319d669c..f3f0afebe5 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 @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory
    -

    注意: A WebAssembly 页面的大小为一个常量 65,536 字节,即64KB。

    +

    备注:: A WebAssembly 页面的大小为一个常量 65,536 字节,即64KB。

    异常

    @@ -95,13 +95,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory -

    浏览器兼容性

    -
    - - -

    {{Compat("javascript.builtins.WebAssembly.Memory")}}

    -
    +{{Compat}}

    参见

    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 5f3839d6b2..eb2fee5a2a 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 @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Module

    构造函数语法

    -

    重要提示:由于大型模块的编译可能很消耗资源,开发人员只有在绝对需要同步编译时,才使用 Module() 构造函数;其他情况下,应该使用异步 {{jsxref("WebAssembly.compile()")}} 方法。

    +

    警告:由于大型模块的编译可能很消耗资源,开发人员只有在绝对需要同步编译时,才使用 Module() 构造函数;其他情况下,应该使用异步 {{jsxref("WebAssembly.compile()")}} 方法。

    var myModule = new WebAssembly.Module(bufferSource);
    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 5e1b468f38..ff779c45fb 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 @@ -10,7 +10,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/WebAssembly/Table

    这是一个包装了WebAssemble Table 的Javascript包装对象,具有类数组结构,存储了多个函数引用。在Javascript或者WebAssemble中创建Table 对象可以同时被Javascript或WebAssemble 访问和更改。

    -

    Note: Tables 对象目前只能存储函数引用,不过在将来可能会被扩展。

    +

    备注:: Tables 对象目前只能存储函数引用,不过在将来可能会被扩展。

    语法

    diff --git a/files/zh-cn/web/javascript/reference/index.html b/files/zh-cn/web/javascript/reference/index.html index 62768a63d0..5ee1ba6672 100644 --- a/files/zh-cn/web/javascript/reference/index.html +++ b/files/zh-cn/web/javascript/reference/index.html @@ -8,416 +8,367 @@ tags: - 参考 translation_of: Web/JavaScript/Reference --- +
    {{JsSidebar}}
    -
    在 MDN 的 JavaScript 分区中,这一部分被作为 Javascript 的资料库。阅读关于该参考以了解更多。
    +
    + 在 MDN 的 JavaScript 分区中,这一部分被作为 Javascript 的资料库。阅读关于该参考以了解更多。 +

    内置

    {{JSxRef("Global_Objects", "JavaScript 标准内置对象")}}, 以及他们的方法和属性.

    -
      -
    • -

      值属性

      - -
        -
      • {{JSxRef("Infinity")}}
      • -
      • {{JSxRef("NaN")}}
      • -
      • {{JSxRef("undefined")}}
      • -
      • {{JSxRef("globalThis")}}
      • -
      -
    • -
    • -

      Function 属性

      - -
        -
      • {{JSxRef("Global_Objects/eval", "eval()")}}
      • -
      • {{JSxRef("Global_Objects/isFinite", "isFinite()")}}
      • -
      • {{JSxRef("Global_Objects/isNaN", "isNaN()")}}
      • -
      • {{JSxRef("Global_Objects/parseFloat", "parseFloat()")}}
      • -
      • {{JSxRef("Global_Objects/parseInt", "parseInt()")}}
      • -
      • {{JSxRef("Global_Objects/decodeURI", "decodeURI()")}}
      • -
      • {{JSxRef("Global_Objects/decodeURIComponent", "decodeURIComponent()")}}
      • -
      • {{JSxRef("Global_Objects/encodeURI", "encodeURI()")}}
      • -
      • {{JSxRef("Global_Objects/encodeURIComponent", "encodeURIComponent()")}}
      • -
      -
    • -
    • -

      基本对象

      - -
        -
      • {{JSxRef("Object")}}
      • -
      • {{JSxRef("Function")}}
      • -
      • {{JSxRef("Boolean")}}
      • -
      • {{JSxRef("Symbol")}}
      • -
      -
    • -
    • -

      错误对象

      - -
        -
      • {{JSxRef("Error")}}
      • -
      • {{JSxRef("AggregateError")}}
      • -
      • {{JSxRef("EvalError")}}
      • -
      • {{JSxRef("InternalError")}}
      • -
      • {{JSxRef("RangeError")}}
      • -
      • {{JSxRef("ReferenceError")}}
      • -
      • {{JSxRef("SyntaxError")}}
      • -
      • {{JSxRef("TypeError")}}
      • -
      • {{JSxRef("URIError")}}
      • -
      -
    • -
    - -
      -
    • -

      Numbers & dates

      - -
        -
      • {{JSxRef("Number")}}
      • -
      • {{JSxRef("BigInt")}}
      • -
      • {{JSxRef("Math")}}
      • -
      • {{JSxRef("Date")}}
      • -
      -
    • -
    • -

      文本处理

      - -
        -
      • {{JSxRef("String")}} {{JSxRef("RegExp")}}
      • -
      -
    • -
    • -

      索引集合类

      - -
        -
      • {{JSxRef("Array")}}
      • -
      • {{JSxRef("Int8Array")}}
      • -
      • {{JSxRef("Uint8Array")}}
      • -
      • {{JSxRef("Uint8ClampedArray")}}
      • -
      • {{JSxRef("Int16Array")}}
      • -
      • {{JSxRef("Uint16Array")}}
      • -
      • {{JSxRef("Int32Array")}}
      • -
      • {{JSxRef("Uint32Array")}}
      • -
      • {{JSxRef("Float32Array")}}
      • -
      • {{JSxRef("Float64Array")}}
      • -
      • {{JSxRef("BigInt64Array")}}
      • -
      • {{JSxRef("BigUint64Array")}}
      • -
      -
    • -
    • -

      Keyed collections

      - -
        -
      • {{JSxRef("Map")}}
      • -
      • {{JSxRef("Set")}}
      • -
      • {{JSxRef("WeakMap")}}
      • -
      • {{JSxRef("WeakSet")}}
      • -
      -
    • -
    - -
      -
    • -

      结构化数据

      - -
        -
      • {{JSxRef("ArrayBuffer")}}
      • -
      • {{JSxRef("SharedArrayBuffer")}}
      • -
      • {{JSxRef("Atomics")}}
      • -
      • {{JSxRef("DataView")}}
      • -
      • {{JSxRef("JSON")}}
      • -
      -
    • -
    • -

      控制抽象化

      - -
        -
      • {{JSxRef("Promise")}}
      • -
      • {{JSxRef("Generator")}}
      • -
      • {{JSxRef("GeneratorFunction")}}
      • -
      • {{JSxRef("AsyncFunction")}}
      • -
      -
    • -
    • -

      反射

      - -
        -
      • {{JSxRef("Reflect")}}
      • -
      • {{JSxRef("Proxy")}}
      • -
      -
    • -
    • -

      国际化

      - -
        -
      • {{JSxRef("Intl")}}
      • -
      • {{JSxRef("Global_Objects/Intl/Collator", "Intl.Collator")}}
      • -
      • {{JSxRef("Global_Objects/Intl/DateTimeFormat", "Intl.DateTimeFormat")}}
      • -
      • {{JSxRef("Global_Objects/Intl/DisplayNames", "Intl.DisplayNames")}}
      • -
      • {{JSxRef("Global_Objects/Intl/ListFormat", "Intl.ListFormat")}}
      • -
      • {{JSxRef("Global_Objects/Intl/Locale", "Intl.Locale")}}
      • -
      • {{JSxRef("Global_Objects/Intl/NumberFormat", "Intl.NumberFormat")}}
      • -
      • {{JSxRef("Global_Objects/Intl/PluralRules", "Intl.PluralRules")}}
      • -
      • {{JSxRef("Global_Objects/Intl/RelativeTimeFormat", "Intl.RelativeTimeFormat")}}
      • -
      -
    • -
    - -
      -
    • WebAssembly - -
        -
      • {{JSxRef("WebAssembly")}}
      • -
      • {{JSxRef("WebAssembly.Module")}}
      • -
      • {{JSxRef("WebAssembly.Instance")}}
      • -
      • {{JSxRef("WebAssembly.Memory")}}
      • -
      • {{JSxRef("WebAssembly.Table")}}
      • -
      • {{JSxRef("WebAssembly.CompileError")}}
      • -
      • {{JSxRef("WebAssembly.LinkError")}}
      • -
      • {{JSxRef("WebAssembly.RuntimeError")}}
      • -
      -
    • +

      值属性

      + +
        +
      • {{JSxRef("Infinity")}}
      • +
      • {{JSxRef("NaN")}}
      • +
      • {{JSxRef("undefined")}}
      • +
      • {{JSxRef("globalThis")}}
      • +
      + +

      Function 属性

      + +
        +
      • {{JSxRef("Global_Objects/eval", "eval()")}}
      • +
      • {{JSxRef("Global_Objects/isFinite", "isFinite()")}}
      • +
      • {{JSxRef("Global_Objects/isNaN", "isNaN()")}}
      • +
      • {{JSxRef("Global_Objects/parseFloat", "parseFloat()")}}
      • +
      • {{JSxRef("Global_Objects/parseInt", "parseInt()")}}
      • +
      • {{JSxRef("Global_Objects/decodeURI", "decodeURI()")}}
      • +
      • {{JSxRef("Global_Objects/decodeURIComponent", "decodeURIComponent()")}}
      • +
      • {{JSxRef("Global_Objects/encodeURI", "encodeURI()")}}
      • +
      • {{JSxRef("Global_Objects/encodeURIComponent", "encodeURIComponent()")}}
      • +
      + +

      基本对象

      + +
        +
      • {{JSxRef("Object")}}
      • +
      • {{JSxRef("Function")}}
      • +
      • {{JSxRef("Boolean")}}
      • +
      • {{JSxRef("Symbol")}}
      • +
      + +

      错误对象

      + +
        +
      • {{JSxRef("Error")}}
      • +
      • {{JSxRef("AggregateError")}}
      • +
      • {{JSxRef("EvalError")}}
      • +
      • {{JSxRef("InternalError")}}
      • +
      • {{JSxRef("RangeError")}}
      • +
      • {{JSxRef("ReferenceError")}}
      • +
      • {{JSxRef("SyntaxError")}}
      • +
      • {{JSxRef("TypeError")}}
      • +
      • {{JSxRef("URIError")}}
      • +
      + +

      Numbers & dates

      + +
        +
      • {{JSxRef("Number")}}
      • +
      • {{JSxRef("BigInt")}}
      • +
      • {{JSxRef("Math")}}
      • +
      • {{JSxRef("Date")}}
      • +
      + +

      文本处理

      + +
        +
      • {{JSxRef("String")}} {{JSxRef("RegExp")}}
      • +
      + +

      索引集合类

      + +
        +
      • {{JSxRef("Array")}}
      • +
      • {{JSxRef("Int8Array")}}
      • +
      • {{JSxRef("Uint8Array")}}
      • +
      • {{JSxRef("Uint8ClampedArray")}}
      • +
      • {{JSxRef("Int16Array")}}
      • +
      • {{JSxRef("Uint16Array")}}
      • +
      • {{JSxRef("Int32Array")}}
      • +
      • {{JSxRef("Uint32Array")}}
      • +
      • {{JSxRef("Float32Array")}}
      • +
      • {{JSxRef("Float64Array")}}
      • +
      • {{JSxRef("BigInt64Array")}}
      • +
      • {{JSxRef("BigUint64Array")}}
      • +
      + +

      Keyed collections

      + +
        +
      • {{JSxRef("Map")}}
      • +
      • {{JSxRef("Set")}}
      • +
      • {{JSxRef("WeakMap")}}
      • +
      • {{JSxRef("WeakSet")}}
      • +
      + +

      结构化数据

      + +
        +
      • {{JSxRef("ArrayBuffer")}}
      • +
      • {{JSxRef("SharedArrayBuffer")}}
      • +
      • {{JSxRef("Atomics")}}
      • +
      • {{JSxRef("DataView")}}
      • +
      • {{JSxRef("JSON")}}
      • +
      + +

      控制抽象化

      + +
        +
      • {{JSxRef("Promise")}}
      • +
      • {{JSxRef("Generator")}}
      • +
      • {{JSxRef("GeneratorFunction")}}
      • +
      • {{JSxRef("AsyncFunction")}}
      • +
      + +

      反射

      + +
        +
      • {{JSxRef("Reflect")}}
      • +
      • {{JSxRef("Proxy")}}
      • +
      + +

      国际化

      + +
        +
      • {{JSxRef("Intl")}}
      • +
      • {{JSxRef("Global_Objects/Intl/Collator", "Intl.Collator")}}
      • +
      • {{JSxRef("Global_Objects/Intl/DateTimeFormat", "Intl.DateTimeFormat")}}
      • +
      • {{JSxRef("Global_Objects/Intl/DisplayNames", "Intl.DisplayNames")}}
      • +
      • {{JSxRef("Global_Objects/Intl/ListFormat", "Intl.ListFormat")}}
      • +
      • {{JSxRef("Global_Objects/Intl/Locale", "Intl.Locale")}}
      • +
      • {{JSxRef("Global_Objects/Intl/NumberFormat", "Intl.NumberFormat")}}
      • +
      • {{JSxRef("Global_Objects/Intl/PluralRules", "Intl.PluralRules")}}
      • +
      • {{JSxRef("Global_Objects/Intl/RelativeTimeFormat", "Intl.RelativeTimeFormat")}}
      • +
      + +

      WebAssembly

      + +
        +
      • {{JSxRef("WebAssembly")}}
      • +
      • {{JSxRef("WebAssembly.Module")}}
      • +
      • {{JSxRef("WebAssembly.Instance")}}
      • +
      • {{JSxRef("WebAssembly.Memory")}}
      • +
      • {{JSxRef("WebAssembly.Table")}}
      • +
      • {{JSxRef("WebAssembly.CompileError")}}
      • +
      • {{JSxRef("WebAssembly.LinkError")}}
      • +
      • {{JSxRef("WebAssembly.RuntimeError")}}

      语句

      {{JSxRef("Statements", "语句和声明")}}

      -
        -
      • -

        控制流

        - -
          -
        • {{jsxref("Statements/block", "Block")}}
        • -
        • {{jsxref("Statements/break", "break")}}
        • -
        • {{jsxref("Statements/continue", "continue")}}
        • -
        • {{jsxref("Statements/Empty", "Empty")}}
        • -
        • {{jsxref("Statements/if...else", "if...else")}}
        • -
        • {{jsxref("Statements/switch", "switch")}}
        • -
        • {{jsxref("Statements/throw", "throw")}}
        • -
        • {{jsxref("Statements/try...catch", "try...catch")}}
        • -
        -
      • -
      • -

        声明

        - -
          -
        • {{jsxref("Statements/var", "var")}}
        • -
        • {{jsxref("Statements/let", "let")}}
        • -
        • {{jsxref("Statements/const", "const")}}
        • -
        -
      • -
      • -

        函数和类

        - -
          -
        • {{jsxref("Statements/function", "function")}}
        • -
        • {{jsxref("Statements/function*", "function*")}}
        • -
        • {{jsxref("Statements/async_function", "async function")}}
        • -
        • {{jsxref("Statements/return", "return")}}
        • -
        • {{jsxref("Statements/class", "class")}}
        • -
        -
      • -
      • -

        迭代

        - -
          -
        • {{jsxref("Statements/do...while", "do...while")}}
        • -
        • {{jsxref("Statements/for", "for")}}
        • -
        • {{jsxref("Statements/for_each...in", "for each...in")}}
        • -
        • {{jsxref("Statements/for...in", "for...in")}}
        • -
        • {{jsxref("Statements/for...of", "for...of")}}
        • -
        • {{jsxref("Statements/for-await...of", "for await...of")}}
        • -
        • {{jsxref("Statements/while", "while")}}
        • -
        -
      • -
      - -
        -
      • -

        其他

        - -
          -
        • {{jsxref("Statements/debugger", "debugger")}}
        • -
        • {{jsxref("Statements/import", "import")}}
        • -
        • {{jsxref("Statements/label", "label")}}
        • -
        • {{jsxref("Statements/with", "with")}}
        • -
        -
      • +

        控制流

        + +
          +
        • {{jsxref("Statements/block", "Block")}}
        • +
        • {{jsxref("Statements/break", "break")}}
        • +
        • {{jsxref("Statements/continue", "continue")}}
        • +
        • {{jsxref("Statements/Empty", "Empty")}}
        • +
        • {{jsxref("Statements/if...else", "if...else")}}
        • +
        • {{jsxref("Statements/switch", "switch")}}
        • +
        • {{jsxref("Statements/throw", "throw")}}
        • +
        • {{jsxref("Statements/try...catch", "try...catch")}}
        +

        声明

        + +
          +
        • {{jsxref("Statements/var", "var")}}
        • +
        • {{jsxref("Statements/let", "let")}}
        • +
        • {{jsxref("Statements/const", "const")}}
        • +
        + +

        函数和类

        + +
          +
        • {{jsxref("Statements/function", "function")}}
        • +
        • {{jsxref("Statements/function*", "function*")}}
        • +
        • {{jsxref("Statements/async_function", "async function")}}
        • +
        • {{jsxref("Statements/return", "return")}}
        • +
        • {{jsxref("Statements/class", "class")}}
        • +
        + +

        迭代

        + +
          +
        • {{jsxref("Statements/do...while", "do...while")}}
        • +
        • {{jsxref("Statements/for", "for")}}
        • +
        • {{jsxref("Statements/for_each...in", "for each...in")}}
        • +
        • {{jsxref("Statements/for...in", "for...in")}}
        • +
        • {{jsxref("Statements/for...of", "for...of")}}
        • +
        • {{jsxref("Statements/for-await...of", "for await...of")}}
        • +
        • {{jsxref("Statements/while", "while")}}
        • +
        + +

        其他

        + +
          +
        • {{jsxref("Statements/debugger", "debugger")}}
        • +
        • {{jsxref("Statements/import", "import")}}
        • +
        • {{jsxref("Statements/label", "label")}}
        • +
        • {{jsxref("Statements/with", "with")}}
        • +
        + +

        表达式和运算符

        {{JSxRef("Operators", "表达式和运算符")}}. 

        -
        -
          -
        • -

          Primary expressions

          - -
            -
          • {{JSxRef("Operators/this", "this")}}
          • -
          • {{JSxRef("Operators/function", "function")}}
          • -
          • {{JSxRef("Operators/class", "class")}}
          • -
          • {{JSxRef("Operators/function*", "function*")}}
          • -
          • {{JSxRef("Operators/yield", "yield")}}
          • -
          • {{JSxRef("Operators/yield*", "yield*")}}
          • -
          • {{JSxRef("Operators/async_function", "async function")}}
          • -
          • {{JSxRef("Operators/await", "await")}}
          • -
          • {{JSxRef("Global_Objects/Array", "[]")}}
          • -
          • {{JSxRef("Operators/Object_initializer", "{}")}}
          • -
          • {{JSxRef("Global_Objects/RegExp", "/ab+c/i")}}
          • -
          • {{JSxRef("Operators/Grouping", "( )")}}
          • -
          • {{JSxRef("null")}}
          • -
          -
        • -
        • -

          Left-hand-side expressions

          - -
            -
          • {{JSxRef("Operators/Property_accessors", "Property accessors", "", 1)}}
          • -
          • {{JSxRef("Operators/new", "new")}}
          • -
          • {{JSxRef("Operators/new%2Etarget", "new.target")}}
          • -
          • {{JSxRef("Operators/super", "super")}}
          • -
          • {{JSxRef("Operators/Spread_syntax", "...obj")}}
          • -
          -
        • -
        • -

          Increment & decrement

          - -
            -
          • {{JSxRef("Operators/Arithmetic_Operators", "A++", "#Increment")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "A--", "#Decrement")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "++A", "#Increment")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "--A", "#Decrement")}}
          • -
          -
        • -
        • -

          一元运算符

          - -
            -
          • {{JSxRef("Operators/delete", "delete")}}
          • -
          • {{JSxRef("Operators/void", "void")}}
          • -
          • {{JSxRef("Operators/typeof", "typeof")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "+", "#Unary_plus")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "-", "#Unary_negation")}}
          • -
          • {{JSxRef("Operators/Bitwise_Operators", "~", "#Bitwise_NOT")}}
          • -
          • {{JSxRef("Operators/Logical_Operators", "!", "#Logical_NOT")}}
          • -
          -
        • -
        - -
          -
        • -

          算术运算符

          - -
            -
          • {{JSxRef("Operators/Arithmetic_Operators", "+", "#Addition")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "-", "#Subtraction")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "/", "#Division")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "*", "#Multiplication")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "%", "#Remainder")}}
          • -
          • {{JSxRef("Operators/Arithmetic_Operators", "**", "#Exponentiation")}}
          • -
          -
        • -
        • -

          关系运算符

          - -
            -
          • {{JSxRef("Operators/in", "in")}}
          • -
          • {{JSxRef("Operators/instanceof", "instanceof")}}
          • -
          • {{JSxRef("Operators/Comparison_Operators", "<", "#Less_than_operator")}}
          • -
          • {{JSxRef("Operators/Comparison_Operators", ">", "#Greater_than_operator")}}
          • -
          • {{JSxRef("Operators/Comparison_Operators", "<=", "#Less_than_or_equal_operator")}}
          • -
          • {{JSxRef("Operators/Comparison_Operators", ">=", "#Greater_than_or_equal_operator")}}
          • -
          -
        • -
        • -

          相等运算符

          - -
            -
          • {{JSxRef("Operators/Comparison_Operators", "==", "#Equality")}}
          • -
          • {{JSxRef("Operators/Comparison_Operators", "!=", "#Inequality")}}
          • -
          • {{JSxRef("Operators/Comparison_Operators", "===", "#Identity")}}
          • -
          • {{JSxRef("Operators/Comparison_Operators", "!==", "#Nonidentity")}}
          • -
          -
        • -
        • -

          位移运算符

          - -
            -
          • {{JSxRef("Operators/Bitwise_Operators", "<<", "#Left_shift")}}
          • -
          • {{JSxRef("Operators/Bitwise_Operators", ">>", "#Right_shift")}}
          • -
          • {{JSxRef("Operators/Bitwise_Operators", ">>>", "#Unsigned_right_shift")}}
          • -
          -
        • -
        - -
          -
        • -

          位运算

          - -
            -
          • {{JSxRef("Operators/Bitwise_Operators", "&", "#Bitwise_AND")}}
          • -
          • {{JSxRef("Operators/Bitwise_Operators", "|", "#Bitwise_OR")}}
          • -
          • {{JSxRef("Operators/Bitwise_Operators", "^", "#Bitwise_XOR")}}
          • -
          -
        • -
        • -

          逻辑运算

          - -
            -
          • {{JSxRef("Operators/Logical_Operators", "&&", "#Logical_AND")}}
          • -
          • {{JSxRef("Operators/Logical_Operators", "||", "#Logical_OR")}}
          • -
          -
        • -
        • -

          条件运算符

          - -
            -
          • {{JSxRef("Operators/Conditional_Operator", "(condition ? ifTrue : ifFalse)")}}
          • -
          -
        • -
        • -

          赋值操作符

          - -
            -
          • {{JSxRef("Operators/Assignment_Operators", "=", "#Assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", "*=", "#Multiplication_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", "/=", "#Division_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", "%=", "#Remainder_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", "+=", "#Addition_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", "-=", "#Subtraction_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", "<<=", "#Left_shift_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", ">>=", "#Right_shift_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", ">>>=", "#Unsigned_right_shift_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", "&=", "#Bitwise_AND_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", "^=", "#Bitwise_XOR_assignment")}}
          • -
          • {{JSxRef("Operators/Assignment_Operators", "|=", "#Bitwise_OR_assignment")}}
          • -
          • {{JSxRef("Operators/Destructuring_assignment", "[a, b] = [1, 2]")}}
          • -
          • {{JSxRef("Operators/Destructuring_assignment", "{a, b} = {a:1, b:2}")}}
          • -
          -
        • +

          Primary expressions

          + +
            +
          • {{JSxRef("Operators/this", "this")}}
          • +
          • {{JSxRef("Operators/function", "function")}}
          • +
          • {{JSxRef("Operators/class", "class")}}
          • +
          • {{JSxRef("Operators/function*", "function*")}}
          • +
          • {{JSxRef("Operators/yield", "yield")}}
          • +
          • {{JSxRef("Operators/yield*", "yield*")}}
          • +
          • {{JSxRef("Operators/async_function", "async function")}}
          • +
          • {{JSxRef("Operators/await", "await")}}
          • +
          • {{JSxRef("Global_Objects/Array", "[]")}}
          • +
          • {{JSxRef("Operators/Object_initializer", "{}")}}
          • +
          • {{JSxRef("Global_Objects/RegExp", "/ab+c/i")}}
          • +
          • {{JSxRef("Operators/Grouping", "( )")}}
          • +
          • {{JSxRef("null")}}
          -
        + +

        Left-hand-side expressions

        + +
          +
        • {{JSxRef("Operators/Property_accessors", "Property accessors", "", 1)}}
        • +
        • {{JSxRef("Operators/new", "new")}}
        • +
        • {{JSxRef("Operators/new%2Etarget", "new.target")}}
        • +
        • {{JSxRef("Operators/super", "super")}}
        • +
        • {{JSxRef("Operators/Spread_syntax", "...obj")}}
        • +
        + +

        Increment & decrement

        + +
          +
        • {{JSxRef("Operators/Arithmetic_Operators", "A++", "#Increment")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "A--", "#Decrement")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "++A", "#Increment")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "--A", "#Decrement")}}
        • +
        + +

        一元运算符

        + +
          +
        • {{JSxRef("Operators/delete", "delete")}}
        • +
        • {{JSxRef("Operators/void", "void")}}
        • +
        • {{JSxRef("Operators/typeof", "typeof")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "+", "#Unary_plus")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "-", "#Unary_negation")}}
        • +
        • {{JSxRef("Operators/Bitwise_Operators", "~", "#Bitwise_NOT")}}
        • +
        • {{JSxRef("Operators/Logical_Operators", "!", "#Logical_NOT")}}
        • +
        + +

        算术运算符

        + +
          +
        • {{JSxRef("Operators/Arithmetic_Operators", "+", "#Addition")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "-", "#Subtraction")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "/", "#Division")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "*", "#Multiplication")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "%", "#Remainder")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "**", "#Exponentiation")}}
        • +
        + +

        关系运算符

        + +
          +
        • {{JSxRef("Operators/in", "in")}}
        • +
        • {{JSxRef("Operators/instanceof", "instanceof")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "<", "#Less_than_operator")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", ">", "#Greater_than_operator")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "<=", "#Less_than_or_equal_operator")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", ">=", "#Greater_than_or_equal_operator")}}
        • +
        + + +

        相等运算符

        + +
          +
        • {{JSxRef("Operators/Comparison_Operators", "==", "#Equality")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "!=", "#Inequality")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "===", "#Identity")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "!==", "#Nonidentity")}}
        • +
        + +

        位移运算符

        + +
          +
        • {{JSxRef("Operators/Bitwise_Operators", "<<", "#Left_shift")}}
        • +
        • {{JSxRef("Operators/Bitwise_Operators", ">>", "#Right_shift")}}
        • +
        • {{JSxRef("Operators/Bitwise_Operators", ">>>", "#Unsigned_right_shift")}}
        • +
        + +

        位运算

        + +
          +
        • {{JSxRef("Operators/Bitwise_Operators", "&", "#Bitwise_AND")}}
        • +
        • {{JSxRef("Operators/Bitwise_Operators", "|", "#Bitwise_OR")}}
        • +
        • {{JSxRef("Operators/Bitwise_Operators", "^", "#Bitwise_XOR")}}
        • +
        + +

        逻辑运算

        + +
          +
        • {{JSxRef("Operators/Logical_Operators", "&&", "#Logical_AND")}}
        • +
        • {{JSxRef("Operators/Logical_Operators", "||", "#Logical_OR")}}
        • +
        + +

        条件运算符

        + +
          +
        • {{JSxRef("Operators/Conditional_Operator", "(condition ? ifTrue : ifFalse)")}}
        • +
        + +

        赋值操作符

        + +
          +
        • {{JSxRef("Operators/Assignment_Operators", "=", "#Assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "*=", "#Multiplication_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "/=", "#Division_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "%=", "#Remainder_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "+=", "#Addition_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "-=", "#Subtraction_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "<<=", "#Left_shift_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", ">>=", "#Right_shift_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", ">>>=", "#Unsigned_right_shift_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "&=", "#Bitwise_AND_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "^=", "#Bitwise_XOR_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "|=", "#Bitwise_OR_assignment")}}
        • +
        • {{JSxRef("Operators/Destructuring_assignment", "[a, b] = [1, 2]")}}
        • +
        • {{JSxRef("Operators/Destructuring_assignment", "{a, b} = {a:1, b:2}")}}
        • +
        +

        函数

        本章介绍如何使用 JavaScript函数 来开发应用程序。

        附加参考页面

        diff --git a/files/zh-cn/web/javascript/reference/lexical_grammar/index.html b/files/zh-cn/web/javascript/reference/lexical_grammar/index.html index c862bf1e70..d57090cf2b 100644 --- a/files/zh-cn/web/javascript/reference/lexical_grammar/index.html +++ b/files/zh-cn/web/javascript/reference/lexical_grammar/index.html @@ -219,12 +219,12 @@ comment();
    console.log("Hello world");
    -
    -

    注意:JavaScript 中的 hashbang 注释模仿 Unix 中的 shebangs,用于指定适当的解释器运行文件。

    +
    +

    备注::JavaScript 中的 hashbang 注释模仿 Unix 中的 shebangs,用于指定适当的解释器运行文件。

    -
    -

    尽管在 hashbang 注释之前的 BOM 在浏览器中能工作,但不建议在具有 hashbang 的脚本中使用 BOM。当您尝试在 Unix/Linux 中运行脚本时,有 BOM 将不工作。因此,如果要直接从 shell 运行脚本,请使用没有 BOM 的 UTF-8。

    +
    +

    警告:尽管在 hashbang 注释之前的 BOM 在浏览器中能工作,但不建议在具有 hashbang 的脚本中使用 BOM。当您尝试在 Unix/Linux 中运行脚本时,有 BOM 将不工作。因此,如果要直接从 shell 运行脚本,请使用没有 BOM 的 UTF-8。

    您只能使用 #! 注释样式以指定 JavaScript 解释器。在所有其他情况下,只需使用 // 注释(或多行注释)。

    diff --git a/files/zh-cn/web/javascript/reference/operators/await/index.html b/files/zh-cn/web/javascript/reference/operators/await/index.html index 4f0ea9b0c3..463f0e8ea1 100644 --- a/files/zh-cn/web/javascript/reference/operators/await/index.html +++ b/files/zh-cn/web/javascript/reference/operators/await/index.html @@ -95,59 +95,7 @@ f3();

    浏览器兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerEdgeOperaSafari (WebKit)
    基本支持{{CompatChrome(55)}}{{CompatGeckoDesktop("52.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatOpera(42)}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
     基本支持{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("52.0")}}{{CompatUnknown}}{{CompatOpera(42)}}{{CompatUnknown}}{{CompatChrome(55)}}
    -
    +{{Compat}}

    查看更多

    diff --git a/files/zh-cn/web/javascript/reference/operators/bitwise_and/index.html b/files/zh-cn/web/javascript/reference/operators/bitwise_and/index.html index 017d0d464c..28489e61a3 100644 --- a/files/zh-cn/web/javascript/reference/operators/bitwise_and/index.html +++ b/files/zh-cn/web/javascript/reference/operators/bitwise_and/index.html @@ -31,9 +31,9 @@ After: 10100000000000000110000000000001
    - - - + + + diff --git a/files/zh-cn/web/javascript/reference/operators/bitwise_not/index.html b/files/zh-cn/web/javascript/reference/operators/bitwise_not/index.html index 46ffd369dd..8cd674a8cb 100644 --- a/files/zh-cn/web/javascript/reference/operators/bitwise_not/index.html +++ b/files/zh-cn/web/javascript/reference/operators/bitwise_not/index.html @@ -38,8 +38,8 @@ After: 10100000000000000110000000000001
    aba AND baba AND b
    - - + + diff --git a/files/zh-cn/web/javascript/reference/operators/bitwise_or/index.html b/files/zh-cn/web/javascript/reference/operators/bitwise_or/index.html index 2f83d5d956..5c5810d152 100644 --- a/files/zh-cn/web/javascript/reference/operators/bitwise_or/index.html +++ b/files/zh-cn/web/javascript/reference/operators/bitwise_or/index.html @@ -30,9 +30,9 @@ After: 10100000000000000110000000000001
    aNOT aaNOT a
    - - - + + + diff --git a/files/zh-cn/web/javascript/reference/operators/bitwise_xor/index.html b/files/zh-cn/web/javascript/reference/operators/bitwise_xor/index.html index 1ec5d48f0a..9b670f4a58 100644 --- a/files/zh-cn/web/javascript/reference/operators/bitwise_xor/index.html +++ b/files/zh-cn/web/javascript/reference/operators/bitwise_xor/index.html @@ -30,9 +30,9 @@ After: 10100000000000000110000000000001
    aba OR baba OR b
    - - - + + + diff --git a/files/zh-cn/web/javascript/reference/operators/comma_operator/index.html b/files/zh-cn/web/javascript/reference/operators/comma_operator/index.html index cc7b2f83a8..1c9ca88054 100644 --- a/files/zh-cn/web/javascript/reference/operators/comma_operator/index.html +++ b/files/zh-cn/web/javascript/reference/operators/comma_operator/index.html @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Operators/Comma_Operator

    假设 a 是一个二维数组,每一维度包含10个元素,则下面的代码使用逗号操作符一次递增/递减两个变量。需要注意的是,var 语句中的逗号不是逗号操作符,因为它不是存在于一个表达式中。尽管从实际效果来看,那个逗号同逗号运算符的表现很相似。但确切地说,它是 var 语句中的一个特殊符号,用于把多个变量声明结合成一个。下面的代码打印一个二维数组中斜线方向的元素:

    -
    for (var i = 0, j = 9; i <= 9; i++, j--)
    +
    for (var i = 0, j = 9; i <= 9; i++, j--)
       document.writeln("a[" + i + "][" + j + "] = " + a[i][j]);

    处理后返回

    diff --git a/files/zh-cn/web/javascript/reference/operators/conditional_operator/index.html b/files/zh-cn/web/javascript/reference/operators/conditional_operator/index.html index cb3153c5ee..720dda3c68 100644 --- a/files/zh-cn/web/javascript/reference/operators/conditional_operator/index.html +++ b/files/zh-cn/web/javascript/reference/operators/conditional_operator/index.html @@ -52,7 +52,7 @@ console.log(greeting({name: 'Alice'})); // "Howdy, Alice" console.log(greeting(null)); // "Howdy, stranger"
    -
    +

    Note: The optional chaining operator 设计用来处理这种使用场景。在本文档写成的时候 (2019.01),这个运算符还处于实验阶段并且没有实现。

    diff --git a/files/zh-cn/web/javascript/reference/operators/delete/index.html b/files/zh-cn/web/javascript/reference/operators/delete/index.html index f8b4e02e0c..f061e72ba2 100644 --- a/files/zh-cn/web/javascript/reference/operators/delete/index.html +++ b/files/zh-cn/web/javascript/reference/operators/delete/index.html @@ -131,8 +131,8 @@ console.log(delete variable2); // false console.log(delete func); // false -
    -

    下文在英文原版中已删除

    +
    +

    备注:下文在英文原版中已删除

    任何使用var声明的变量都会被标记为不可设置的。在下面的例子中,salary是不可设置的以及不能被删除的。在非严格模式下,下面的delete操作将会返回false。

    diff --git a/files/zh-cn/web/javascript/reference/operators/destructuring_assignment/index.html b/files/zh-cn/web/javascript/reference/operators/destructuring_assignment/index.html index 93182a3253..05cc98f3a9 100644 --- a/files/zh-cn/web/javascript/reference/operators/destructuring_assignment/index.html +++ b/files/zh-cn/web/javascript/reference/operators/destructuring_assignment/index.html @@ -188,7 +188,7 @@ console.log(q); // true
    -

    注意:赋值语句周围的圆括号 ( ... ) 在使用对象字面量无声明解构赋值时是必须的。

    +

    备注:赋值语句周围的圆括号 ( ... ) 在使用对象字面量无声明解构赋值时是必须的。

    {a, b} = {a: 1, b: 2} 不是有效的独立语法,因为左边的 {a, b} 被认为是一个块而不是对象字面量。

    @@ -259,7 +259,7 @@ drawES2015Chart({ });
    -

    在上面的 drawES2015Chart 的函数签名中,解构的左手边被分配给右手边的空对象字面值:{size = 'big', cords = {x: 0, y: 0}, radius = 25} = {}。你也可以在没有右侧分配的情况下编写函数。但是,如果你忽略了右边的赋值,那么函数会在被调用的时候查找至少一个被提供的参数,而在当前的形式下,你可以直接调用 drawES2015Chart() 而不提供任何参数。如果你希望能够在不提供任何参数的情况下调用该函数,则当前的设计非常有用,而另一种方法在您确保将对象传递给函数时非常有用。

    +

    备注:在上面的 drawES2015Chart 的函数签名中,解构的左手边被分配给右手边的空对象字面值:{size = 'big', cords = {x: 0, y: 0}, radius = 25} = {}。你也可以在没有右侧分配的情况下编写函数。但是,如果你忽略了右边的赋值,那么函数会在被调用的时候查找至少一个被提供的参数,而在当前的形式下,你可以直接调用 drawES2015Chart() 而不提供任何参数。如果你希望能够在不提供任何参数的情况下调用该函数,则当前的设计非常有用,而另一种方法在您确保将对象传递给函数时非常有用。

    解构嵌套对象和数组

    diff --git a/files/zh-cn/web/javascript/reference/operators/function/index.html b/files/zh-cn/web/javascript/reference/operators/function/index.html index c3c9bd85ea..5a69175075 100644 --- a/files/zh-cn/web/javascript/reference/operators/function/index.html +++ b/files/zh-cn/web/javascript/reference/operators/function/index.html @@ -120,55 +120,7 @@ console.log(bar === baz); // false (errors because baz == undefined)

    浏览器兼容性

    -

    {{ CompatibilityTable() }}

    - -
    -
    aba XOR baba XOR b
    - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}{{ CompatVersionUnknown() }}
    -
    +{{Compat}}

    相关链接

    diff --git a/files/zh-cn/web/javascript/reference/operators/index.html b/files/zh-cn/web/javascript/reference/operators/index.html index 810ccb74cd..82ff728c29 100644 --- a/files/zh-cn/web/javascript/reference/operators/index.html +++ b/files/zh-cn/web/javascript/reference/operators/index.html @@ -135,7 +135,9 @@ translation_of: Web/JavaScript/Reference/Operators
    大于等于运算符。 
    -
    注意: => 不是运算符,而是{{jsxref("Functions/Arrow_functions", "箭头函数")}}的表示符。
    +
    +

    备注: 不是运算符,而是{{jsxref("Functions/Arrow_functions", "箭头函数")}}的表示符。

    +

    相等运算符

    @@ -241,11 +243,11 @@ translation_of: Web/JavaScript/Reference/Operators

    解构赋值允许你分配数组或者对象变量的属性通过使用规定的语法,其看起来和数组和对象字面量很相似。

    -

    逗号操作符 {{jsxref("Operators/Comma_Operator", ",")}}

    + 逗号操作符 {{jsxref("Operators/Comma_Operator", ",")}}
    逗号操作符允许在一个判断状态中有多个表达式去进行运算并且最后返回最后一个表达式的值。
    -

    非标准化特性 {{JSxRef("Operators/Expression_closures", "Expression closures", "", 1)}} {{non-standard_inline}}{{obsolete_inline(60)}}

    + 非标准化特性 {{JSxRef("Operators/Expression_closures", "Expression closures", "", 1)}} {{non-standard_inline}}{{obsolete_inline(60)}}
    闭包表达式语法是一个缩写简单的函数。
    {{JSxRef("Operators/Legacy_generator_function", "Legacy generator function", "", 1)}} {{non-standard_inline}}{{obsolete_inline(58)}}
    diff --git a/files/zh-cn/web/javascript/reference/operators/instanceof/index.html b/files/zh-cn/web/javascript/reference/operators/instanceof/index.html index f6f1f188f8..bb93a7028e 100644 --- a/files/zh-cn/web/javascript/reference/operators/instanceof/index.html +++ b/files/zh-cn/web/javascript/reference/operators/instanceof/index.html @@ -73,8 +73,12 @@ o3 instanceof C; // true 因为 C.prototype 现在在 o3 的原型链上

    比如检测一个 Nodes 在另一个窗口中是不是 SVGElement,你可以使用myNode instanceof myNode.ownerDocument.defaultView.SVGElement

    -
    Mozilla开发者注意:
    -在代码中使用 XPCOM instanceof 有特殊影响: 如果查询接口成功执行后,obj instanceof xpcomInterface (e.g. Components.interfaces.nsIFile) 调用obj.QueryInterface(xpcomInterface) 并且返回 true 。这种调用的副作用是在一次成功的 instanceof 测试后,你可以在 obj 上使用xpcomInterface 的属性。这与标准的 JavaScript 全局变量不同,即使 obj 来自不同的作用域,obj instanceof xpcomInterface 也可以按预期产生作用。
    +
    +

    + 备注: + 在代码中使用 XPCOM instanceof 有特殊影响: 如果查询接口成功执行后,obj instanceof xpcomInterface (e.g. Components.interfaces.nsIFile) 调用obj.QueryInterface(xpcomInterface) 并且返回 true 。这种调用的副作用是在一次成功的 instanceof 测试后,你可以在 obj 上使用xpcomInterface 的属性。这与标准的 JavaScript 全局变量不同,即使 obj 来自不同的作用域,obj instanceof xpcomInterface 也可以按预期产生作用。 +

    +

    示例

    diff --git a/files/zh-cn/web/javascript/reference/operators/logical_or/index.html b/files/zh-cn/web/javascript/reference/operators/logical_or/index.html index d159e76866..69f521ca62 100644 --- a/files/zh-cn/web/javascript/reference/operators/logical_or/index.html +++ b/files/zh-cn/web/javascript/reference/operators/logical_or/index.html @@ -73,8 +73,8 @@ o9 = false || '' // f || f returns "" o10 = false || varObject // f || object returns varObject -
    -

    Note: If you use this operator to provide a default value to some variable, be aware that any falsy value will not be used. If you only need to filter out {{jsxref("null")}} or {{jsxref("undefined")}}, consider using the nullish coalescing operator.

    +
    +

    备注: If you use this operator to provide a default value to some variable, be aware that any falsy value will not be used. If you only need to filter out {{jsxref("null")}} or {{jsxref("undefined")}}, consider using the nullish coalescing operator.

    Conversion rules for booleans

    diff --git a/files/zh-cn/web/javascript/reference/operators/new/index.html b/files/zh-cn/web/javascript/reference/operators/new/index.html index e44beb9763..4959409c31 100644 --- a/files/zh-cn/web/javascript/reference/operators/new/index.html +++ b/files/zh-cn/web/javascript/reference/operators/new/index.html @@ -83,7 +83,7 @@ console.log(car2.color) // original color
    -

    如果你没有使用 new 运算符, 构造函数会像其他的常规函数一样被调用,不会创建一个对象在这种情况下, this 的指向也是不一样的。

    +

    备注:如果你没有使用 new 运算符, 构造函数会像其他的常规函数一样被调用,不会创建一个对象在这种情况下, this 的指向也是不一样的。

    示例

    diff --git a/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html b/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html index e765e6d66b..9c3f743c8a 100644 --- a/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html +++ b/files/zh-cn/web/javascript/reference/operators/optional_chaining/index.html @@ -61,12 +61,12 @@ let nestedProp = ((temp === null || temp === undefined) ? undefined : temp.secon
    let result = someInterface.customMethod?.();
    -
    -

    注意: 如果存在一个属性名且不是函数, 使用 ?. 仍然会产生一个 {{JSxRef("TypeError")}} 异常 (x.y is not a function).

    +
    +

    备注:如果存在一个属性名且不是函数, 使用 ?. 仍然会产生一个 {{JSxRef("TypeError")}} 异常 (x.y is not a function).

    -
    -

    注意: 如果 someInterface 自身是 null 或者 undefined ,异常 {{JSxRef("TypeError")}} 仍会被抛出 someInterface is null 如果你希望允许 someInterface 也为 null 或者 undefined ,那么你需要像这样写 someInterface?.customMethod?.()

    +
    +

    备注:如果 someInterface 自身是 null 或者 undefined ,异常 {{JSxRef("TypeError")}} 仍会被抛出 someInterface is null 如果你希望允许 someInterface 也为 null 或者 undefined ,那么你需要像这样写 someInterface?.customMethod?.()

    处理可选的回调函数或者事件处理器

    diff --git a/files/zh-cn/web/javascript/reference/operators/property_accessors/index.html b/files/zh-cn/web/javascript/reference/operators/property_accessors/index.html index c7c482256d..6d139479f9 100644 --- a/files/zh-cn/web/javascript/reference/operators/property_accessors/index.html +++ b/files/zh-cn/web/javascript/reference/operators/property_accessors/index.html @@ -23,7 +23,7 @@ object['property']

    描述

    -

    我们可以将对象看做是一个关联数组(或者:映射字典哈希表查询表)。这个数组中的键就是这个对象中属性的名称。通常,当我们提及一个对象的属性时,会对属性与方法之间做个对比。然而,属性与方法之间的区别并不大。一个方法就是一个可以被调用的属性而已,例如一个指向函数 Function 实例的引用可以作为对象属性的值。

    +

    我们可以将对象看做是一个关联数组(或者:映射字典哈希表查询表)。这个数组中的键就是这个对象中属性的名称。通常,当我们提及一个对象的属性时,会对属性与方法之间做个对比。然而,属性与方法之间的区别并不大。一个方法就是一个可以被调用的属性而已,例如一个指向函数 Function 实例的引用可以作为对象属性的值。

    访问对象属性有两种方式:点号表示法和方括号表示法。

    diff --git a/files/zh-cn/web/javascript/reference/operators/this/index.html b/files/zh-cn/web/javascript/reference/operators/this/index.html index 86616407d0..8e79b0d0d5 100644 --- a/files/zh-cn/web/javascript/reference/operators/this/index.html +++ b/files/zh-cn/web/javascript/reference/operators/this/index.html @@ -42,8 +42,8 @@ this.b = "MDN"; console.log(window.b) // "MDN" console.log(b) // "MDN" -
    -

    Note: 你可以使用 {{jsxref("globalThis")}} 获取全局对象,无论你的代码是否在当前上下文运行。

    +
    +

    备注:你可以使用 {{jsxref("globalThis")}} 获取全局对象,无论你的代码是否在当前上下文运行。

    函数上下文

    @@ -72,7 +72,9 @@ f1() === globalThis; f2() === undefined; // true -
    在第二个例子中,this 应是 undefined,因为 f2 是被直接调用的,而不是作为对象的属性或方法调用的(如 window.f2())。有一些浏览器最初在支持严格模式时没有正确实现这个功能,于是它们错误地返回了window对象。
    +
    +

    备注:在第二个例子中,this 应是 undefined,因为 f2 是被直接调用的,而不是作为对象的属性或方法调用的(如 window.f2())。有一些浏览器最初在支持严格模式时没有正确实现这个功能,于是它们错误地返回了window对象。

    +

    如果要想把 this 的值从一个环境传到另一个,就要用 call 或者apply 方法,如下方的示例所示。

    @@ -94,8 +96,8 @@ f2() === undefined; // true new Example(); // ['constructor', 'first', 'second'] -
    -

    注意:静态方法不是 this 的属性,它们只是类自身的属性。

    +
    +

    备注:静态方法不是 this 的属性,它们只是类自身的属性。

    派生类

    @@ -104,7 +106,7 @@ new Example(); // ['constructor', 'first', 'second']
    this = new Base();
    -
    +

    警告:在调用 super() 之前引用 this 会抛出错误。

    @@ -199,7 +201,7 @@ var foo = (() => this); console.log(foo() === globalObject); // true
    -

    注意:如果将this传递给callbind、或者apply来调用箭头函数,它将被忽略。不过你仍然可以为调用添加参数,不过第一个参数(thisArg)应该设置为null

    +

    备注:如果将this传递给callbind、或者apply来调用箭头函数,它将被忽略。不过你仍然可以为调用添加参数,不过第一个参数(thisArg)应该设置为null

    // 接着上面的代码
    @@ -328,7 +330,7 @@ console.log(o.average, o.sum); // logs 2, 6
     

    当一个函数用作构造函数时(使用new关键字),它的this被绑定到正在构造的新对象。

    -

    虽然构造函数返回的默认值是 this 所指的那个对象,但它仍可以手动返回其他的对象(如果返回值不是一个对象,则返回 this 对象)。

    +

    备注:虽然构造函数返回的默认值是 this 所指的那个对象,但它仍可以手动返回其他的对象(如果返回值不是一个对象,则返回 this 对象)。

    /*
    @@ -443,8 +445,8 @@ bird.sayHi(); // Hello from Tweety
     bird.sayBye = car.sayBye;
     bird.sayBye();  // Bye from Ferrari
    -
    -

    注意:类内部总是严格模式。调用一个 this 值为 undefined 的方法会抛出错误。

    +
    +

    备注:类内部总是严格模式。调用一个 this 值为 undefined 的方法会抛出错误。

    规范

    diff --git a/files/zh-cn/web/javascript/reference/operators/typeof/index.html b/files/zh-cn/web/javascript/reference/operators/typeof/index.html index ae77ab6261..1a149d5ed6 100644 --- a/files/zh-cn/web/javascript/reference/operators/typeof/index.html +++ b/files/zh-cn/web/javascript/reference/operators/typeof/index.html @@ -27,9 +27,7 @@ typeof(operand)

    operand

    -
    -
    一个表示对象或{{Glossary("Primitive", "原始值")}}的表达式,其类型将被返回。
    -
    +

    一个表示对象或{{Glossary("Primitive", "原始值")}}的表达式,其类型将被返回。

    描述

    @@ -268,8 +266,6 @@ class newClass{};
    typeof alert === 'object'
    -
    -

    相关链接

      diff --git a/files/zh-cn/web/javascript/reference/statements/async_function/index.html b/files/zh-cn/web/javascript/reference/statements/async_function/index.html index ba79f6a5d2..5088f77130 100644 --- a/files/zh-cn/web/javascript/reference/statements/async_function/index.html +++ b/files/zh-cn/web/javascript/reference/statements/async_function/index.html @@ -35,22 +35,21 @@ translation_of: Web/JavaScript/Reference/Statements/async_function
      要传递给函数的参数的名称。
      statements
      包含函数主体的表达式。可以使用await机制。
      -
      -

      返回值

      -
      -
      一个{{jsxref("Promise")}},这个promise要么会通过一个由async函数返回的值被解决,要么会通过一个从async函数中抛出的(或其中没有被捕获到的)异常被拒绝。
      +

      返回值

      +

      一个{{jsxref("Promise")}},这个promise要么会通过一个由async函数返回的值被解决,要么会通过一个从async函数中抛出的(或其中没有被捕获到的)异常被拒绝。

      +

      描述

      async函数可能包含0个或者多个{{jsxref("Operators/await", "await")}}表达式。await表达式会暂停整个async函数的执行进程并出让其控制权,只有当其等待的基于promise的异步操作被兑现或被拒绝之后才会恢复进程。promise的解决值会被当作该await表达式的返回值。使用async / await关键字就可以在异步代码中使用普通的try / catch代码块。

      -

      await关键字只在async函数内有效。如果你在async函数体之外使用它,就会抛出语法错误 {{jsxref("SyntaxError")}} 。

      +

      备注:await关键字只在async函数内有效。如果你在async函数体之外使用它,就会抛出语法错误 {{jsxref("SyntaxError")}} 。

      -

      async/await的目的为了简化使用基于promise的API时所需的语法。async/await的行为就好像搭配使用了生成器和promise。

      +

      备注:async/await的目的为了简化使用基于promise的API时所需的语法。async/await的行为就好像搭配使用了生成器和promise。

      async函数一定会返回一个promise对象。如果一个async函数的返回值看起来不是promise,那么它将会被隐式地包装在一个promise中。

      @@ -200,6 +199,7 @@ setTimeout(parallelPromise, 13000); // same as parallel
      +

      备注:

      await and parallelism(并行)

      sequentialStart中,程序在第一个await停留了2秒,然后又在第二个await停留了1秒。直到第一个计时器结束后,第二个计时器才被创建。程序需要3秒执行完毕。

      @@ -213,6 +213,7 @@ setTimeout(parallelPromise, 13000); // same as parallel
      +

      警告:

      async/await和Promise#then对比以及错误处理

      大多数async函数也可以使用Promises编写。但是,在错误处理方面,async函数更容易捕获异常错误

      @@ -255,8 +256,8 @@ setTimeout(parallelPromise, 13000); // same as parallel

      注意,在上述示例中,return 语句中没有 await 操作符,因为 async function 的返回值将被隐式地传递给 {{jsxref("Promise.resolve")}}

      -
      -

      return await promiseValue; 与 return promiseValue;的比较

      +
      +

      备注:

      返回值隐式的传递给{{jsxref("Promise.resolve")}},并不意味着return await promiseValue;和return promiseValue;在功能上相同。

      diff --git a/files/zh-cn/web/javascript/reference/statements/break/index.html b/files/zh-cn/web/javascript/reference/statements/break/index.html index cce30700ab..0f61d23f95 100644 --- a/files/zh-cn/web/javascript/reference/statements/break/index.html +++ b/files/zh-cn/web/javascript/reference/statements/break/index.html @@ -68,7 +68,7 @@ switch (food) {

      下面的代码中一起使用 break 语句和被标记的块语句。一个 break 语句必须内嵌在它引用的标记中。注意,inner_block 内嵌在 outer_block 中。

      -
      outer_block:{
      +
      outer_block:{
       
         inner_block:{
           console.log ('1');
      @@ -84,7 +84,7 @@ switch (food) {
       
       

      下面的代码同样使用了 break 语句和被标记的块语句,但是产生了一个语法错误,因为它的 break 语句在 block_1 中,但是引用了 block_2break 语句必须内嵌在它引用的标签中。

      -
      block_1:{
      +
      block_1:{
         console.log ('1');
         break block_2;            // SyntaxError: label not found
       }
      diff --git a/files/zh-cn/web/javascript/reference/statements/class/index.html b/files/zh-cn/web/javascript/reference/statements/class/index.html
      index b4b8afdbd6..f90b560270 100644
      --- a/files/zh-cn/web/javascript/reference/statements/class/index.html
      +++ b/files/zh-cn/web/javascript/reference/statements/class/index.html
      @@ -57,6 +57,7 @@ class Square extends Polygon {
       }
      +

      警告:

      重复定义类

      重复声明一个类会引起类型错误。

      diff --git a/files/zh-cn/web/javascript/reference/statements/continue/index.html b/files/zh-cn/web/javascript/reference/statements/continue/index.html index 9d8954fb84..d356fdde7f 100644 --- a/files/zh-cn/web/javascript/reference/statements/continue/index.html +++ b/files/zh-cn/web/javascript/reference/statements/continue/index.html @@ -40,7 +40,7 @@ translation_of: Web/JavaScript/Reference/Statements/continue

      下述例子展示了一个在i 为 3时执行continue 语句的 {{jsxref("Statements/while", "while")}} 循环。因此,n 的值在几次迭代后分别为 1, 3, 7 和 12 .

      -
      i = 0;
      +
      i = 0;
       n = 0;
       while (i < 5) {
          i++;
      @@ -58,7 +58,7 @@ while (i < 5) {
       
       

      参考 {{jsxref("Statements/label", "label")}} 。

      -
      var i = 0,
      +
      var i = 0,
           j = 8;
       
       checkiandj: while (i < 4) {
      @@ -78,7 +78,7 @@ checkiandj: while (i < 4) {
       
       

      输出:

      -
      "i: 0"
      +
      "i: 0"
       
       // start checkj
       "j: 8"
      diff --git a/files/zh-cn/web/javascript/reference/statements/debugger/index.html b/files/zh-cn/web/javascript/reference/statements/debugger/index.html
      index d87e77bfb8..dc8ca25936 100644
      --- a/files/zh-cn/web/javascript/reference/statements/debugger/index.html
      +++ b/files/zh-cn/web/javascript/reference/statements/debugger/index.html
      @@ -19,14 +19,14 @@ translation_of: Web/JavaScript/Reference/Statements/debugger
       
       

      下面的例子演示了一个包含 debugger 语句的函数,当函数被调用时,会尝试调用一个可用的调试器进行调试。

      -
      function potentiallyBuggyCode() {
      +
      function potentiallyBuggyCode() {
           debugger;
           // do potentially buggy stuff to examine, step through, etc.
       }

      当 debugger 被调用时, 执行暂停在 debugger 语句的位置。就像在脚本源代码中的断点一样。

      -

      Paused at a debugger statement.

      +

      Paused at a debugger statement.

      规范

      diff --git a/files/zh-cn/web/javascript/reference/statements/do...while/index.html b/files/zh-cn/web/javascript/reference/statements/do...while/index.html index 9f013042b9..dffd5e085b 100644 --- a/files/zh-cn/web/javascript/reference/statements/do...while/index.html +++ b/files/zh-cn/web/javascript/reference/statements/do...while/index.html @@ -34,7 +34,7 @@ while (condition);

      HTML 内容

      -
      <div id="example"></div>
      +
      <div id="example"></div>

      JavaScript 内容

      diff --git a/files/zh-cn/web/javascript/reference/statements/export/index.html b/files/zh-cn/web/javascript/reference/statements/export/index.html index bcffc5aafc..8d1e1d3b3a 100644 --- a/files/zh-cn/web/javascript/reference/statements/export/index.html +++ b/files/zh-cn/web/javascript/reference/statements/export/index.html @@ -117,8 +117,8 @@ export { function1, function2 };

      但这里的 function1 和 function2 在当前模块中变得不可用。

      -
      -

      注意:尽管与import等效,但以下语法在语法上无效:

      +
      +

      备注:尽管与import等效,但以下语法在语法上无效:

      import DefaultExport from 'bar.js'; // 有效的
      diff --git a/files/zh-cn/web/javascript/reference/statements/for-await...of/index.html b/files/zh-cn/web/javascript/reference/statements/for-await...of/index.html
      index 597426a1fc..272bc49fb1 100644
      --- a/files/zh-cn/web/javascript/reference/statements/for-await...of/index.html
      +++ b/files/zh-cn/web/javascript/reference/statements/for-await...of/index.html
      @@ -20,8 +20,8 @@ translation_of: Web/JavaScript/Reference/Statements/for-await...of
       
       

      类似于 {{jsxref("Operators/await", "await")}} 运算符一样,该语句只能在一个{{jsxref("Statements/async_function", "async function", "异步函数", 1)}} 内部使用。

      -
      -

      for await...of 不适用于不是异步可迭代的异步迭代器。

      +
      +

      备注:for await...of 不适用于不是异步可迭代的异步迭代器。

      diff --git a/files/zh-cn/web/javascript/reference/statements/for...in/index.html b/files/zh-cn/web/javascript/reference/statements/for...in/index.html index 964a6d7a8d..ed54183732 100644 --- a/files/zh-cn/web/javascript/reference/statements/for...in/index.html +++ b/files/zh-cn/web/javascript/reference/statements/for...in/index.html @@ -27,7 +27,7 @@ translation_of: Web/JavaScript/Reference/Statements/for...in

      数组迭代和 for...in

      -

      提示:for...in不应该用于迭代一个关注索引顺序的 {{jsxref("Array")}}。

      +

      备注:for...in不应该用于迭代一个关注索引顺序的 {{jsxref("Array")}}。

      仅迭代自身的属性

      diff --git a/files/zh-cn/web/javascript/reference/statements/for/index.html b/files/zh-cn/web/javascript/reference/statements/for/index.html index 0a904c3473..9e8eb05f51 100644 --- a/files/zh-cn/web/javascript/reference/statements/for/index.html +++ b/files/zh-cn/web/javascript/reference/statements/for/index.html @@ -110,7 +110,7 @@ showOffsetPos('content'); // top: 153px;"
      -

      提示:这里的分号是强制性的,是 JavaScript 中的少数几种强制分号的情况。如果没有分号,循环声明之后的行将被视为循环语句。

      +

      备注:这里的分号是强制性的,是 JavaScript 中的少数几种强制分号的情况。如果没有分号,循环声明之后的行将被视为循环语句。

      规范

      diff --git a/files/zh-cn/web/javascript/reference/statements/function/index.html b/files/zh-cn/web/javascript/reference/statements/function/index.html index cb225706eb..13efc35a6d 100644 --- a/files/zh-cn/web/javascript/reference/statements/function/index.html +++ b/files/zh-cn/web/javascript/reference/statements/function/index.html @@ -90,7 +90,7 @@ if (true) {

      JavaScript 中的函数声明被提升到了函数定义。你可以在函数声明之前使用该函数:

      -
      hoisted(); // logs "foo"
      +
      hoisted(); // logs "foo"
       
       function hoisted() {
         console.log('foo');
      @@ -98,10 +98,10 @@ function hoisted() {
       
      -

      注意 :函数表达式{{jsxref("Operators/function", "function expressions")}} 不会被提升:

      +

      备注:函数表达式{{jsxref("Operators/function", "function expressions")}} 不会被提升:

      -
      notHoisted(); // TypeError: notHoisted is not a function
      +
      notHoisted(); // TypeError: notHoisted is not a function
       
       var notHoisted = function() {
         console.log('bar');
      @@ -114,7 +114,7 @@ var notHoisted = function() {
       
       

      下面的代码声明了一个函数,该函数返回了销售的总金额, 参数是产品a,b,c分别的销售的数量.

      -
      function calc_sales(units_a, units_b, units_c) {functionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunction
      +
      function calc_sales(units_a, units_b, units_c) {functionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunctionfunction
          return units_a*79 + units_b * 129 + units_c * 699;
       }
      diff --git a/files/zh-cn/web/javascript/reference/statements/import/index.html b/files/zh-cn/web/javascript/reference/statements/import/index.html index 8daa4187e2..4b59374f0a 100644 --- a/files/zh-cn/web/javascript/reference/statements/import/index.html +++ b/files/zh-cn/web/javascript/reference/statements/import/index.html @@ -21,7 +21,7 @@ translation_of: Web/JavaScript/Reference/Statements/import

      语法

      -
      import defaultExport from "module-name";
      +
      import defaultExport from "module-name";
       import * as name from "module-name";
       import { export } from "module-name";
       import { export as alias } from "module-name";
      diff --git a/files/zh-cn/web/javascript/reference/statements/return/index.html b/files/zh-cn/web/javascript/reference/statements/return/index.html
      index 473f330f50..e5a09d5a84 100644
      --- a/files/zh-cn/web/javascript/reference/statements/return/index.html
      +++ b/files/zh-cn/web/javascript/reference/statements/return/index.html
      @@ -57,7 +57,7 @@ a + b;

      控制台会警告“unreachable code after return statement”。

      -

      从 Gecko 40 {{geckoRelease(40)}}开始,如果在一个 return 语句后发现无法访问的代码,控制台将会显示一个警告。

      +

      备注:从 Gecko 40 {{geckoRelease(40)}}开始,如果在一个 return 语句后发现无法访问的代码,控制台将会显示一个警告。

      示例

      diff --git a/files/zh-cn/web/javascript/reference/statements/with/index.html b/files/zh-cn/web/javascript/reference/statements/with/index.html index cca0407da3..93d4270d2e 100644 --- a/files/zh-cn/web/javascript/reference/statements/with/index.html +++ b/files/zh-cn/web/javascript/reference/statements/with/index.html @@ -7,7 +7,9 @@ tags: - Statement translation_of: Web/JavaScript/Reference/Statements/with --- -
      不建议使用with语句,因为它可能是混淆错误和兼容性问题的根源。有关详细信息,请参阅下面“描述”一节中的“语意不明的弊端”部分。
      +
      +

      警告:不建议使用with语句,因为它可能是混淆错误和兼容性问题的根源。有关详细信息,请参阅下面“描述”一节中的“语意不明的弊端”部分。

      +
      {{jsSidebar("Statements")}}
      @@ -31,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Statements/with

      JavaScript查找某个未使用命名空间的变量时,会通过作用域链来查找,作用域链是跟执行代码的context或者包含这个变量的函数有关。'with'语句将某个对象添加到作用域链的顶部,如果在statement中有某个未使用命名空间的变量,跟作用域链中的某个属性同名,则这个变量将指向这个属性值。如果沒有同名的属性,则将拋出{{jsxref("ReferenceError")}}异常。

      -
      不推荐使用with,在 ECMAScript 5 严格模式中该标签已被禁止。推荐的替代方案是声明一个临时变量来承载你所需要的属性。
      +

      备注:不推荐使用with,在 ECMAScript 5 严格模式中该标签已被禁止。推荐的替代方案是声明一个临时变量来承载你所需要的属性。

      性能方面的利与弊

      diff --git a/files/zh-cn/web/javascript/reference/strict_mode/index.html b/files/zh-cn/web/javascript/reference/strict_mode/index.html index c4c8dbfb7d..21b45102ab 100644 --- a/files/zh-cn/web/javascript/reference/strict_mode/index.html +++ b/files/zh-cn/web/javascript/reference/strict_mode/index.html @@ -9,7 +9,9 @@ translation_of: Web/JavaScript/Reference/Strict_mode ---
      {{JsSidebar("More")}}
      -
      有时你会看到非严格模式,被称为“sloppy mode”。这不是一个官方术语,但以防万一,你应该意识到这一点。
      +
      +

      备注:有时你会看到非严格模式,被称为“sloppy mode”。这不是一个官方术语,但以防万一,你应该意识到这一点。

      +
      ECMAScript 5严格模式是采用具有限制性JavaScript变体的一种方式,从而使代码隐式地脱离“马虎模式/稀松模式/懒散模式“(sloppy)模式。
      @@ -112,7 +114,7 @@ delete Object.prototype; // 抛出TypeError错误

      第四,在Gecko版本34之前,严格模式要求一个对象内的所有属性名在对象内必须唯一。正常模式下重名属性是允许的,最后一个重名的属性决定其属性值。因为只有最后一个属性起作用,当代码要去改变属性值而不是修改最后一个重名属性的时候,复制这个对象就产生一连串的bug。在严格模式下,重名属性被认为是语法错误:

      -

      这个问题在ECMAScript6中已经不复存在({{bug(1041128)}})。

      +

      备注:这个问题在ECMAScript6中已经不复存在({{bug(1041128)}})。

      "use strict";
      diff --git a/files/zh-cn/web/javascript/reference/strict_mode/transitioning_to_strict_mode/index.html b/files/zh-cn/web/javascript/reference/strict_mode/transitioning_to_strict_mode/index.html
      index 740a018fb9..c9675cff79 100644
      --- a/files/zh-cn/web/javascript/reference/strict_mode/transitioning_to_strict_mode/index.html
      +++ b/files/zh-cn/web/javascript/reference/strict_mode/transitioning_to_strict_mode/index.html
      @@ -21,8 +21,8 @@ translation_of: Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mod
       
       
      • 八进制语法:var n = 023和var s = "\047"
      • -
      • with语句
      • -
      • 使用delete删除一个变量名(而不是属性名):delete myVariable
      • +
      • with语句
      • +
      • 使用delete删除一个变量名(而不是属性名):delete myVariable
      • 使用evalarguments作为变量名或函数名
      • 使用未来保留字(也许会在ECMAScript 6中使用):implements, interface, let, package, private, protected, public, static,和yield作为变量名或函数名
      • 在语句块中使用函数声明:if(a<b){ function f(){} }
      • diff --git a/files/zh-cn/web/javascript/reference/template_literals/index.html b/files/zh-cn/web/javascript/reference/template_literals/index.html index dbd08899c1..87655274ba 100644 --- a/files/zh-cn/web/javascript/reference/template_literals/index.html +++ b/files/zh-cn/web/javascript/reference/template_literals/index.html @@ -170,7 +170,7 @@ tag`string text line 1 \n string text line 2`;

        另外,使用{{jsxref("String.raw()")}} 方法创建原始字符串和使用默认模板函数和字符串连接创建是一样的。

        -
        var str = String.raw`Hi\n${2+3}!`;var`Hi\n${2+3}
        +
        var str = String.raw`Hi\n${2+3}!`;var`Hi\n${2+3}
         // "Hi\\n5!"
         
         str.length;.
        @@ -245,11 +245,7 @@ latex`\unicode`
         
         

        浏览器兼容

        -
        - - -

        {{Compat("javascript.grammar.template_literals")}}

        -
        +{{Compat}}

        相关链接

        -- cgit v1.2.3-54-g00ecf