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) --- .../a_re-introduction_to_javascript/index.html | 40 +- .../web/javascript/about_javascript/index.html | 3 +- files/zh-cn/web/javascript/closures/index.html | 4 +- .../web/javascript/data_structures/index.html | 2 +- .../equality_comparisons_and_sameness/index.html | 5 +- files/zh-cn/web/javascript/eventloop/index.html | 4 +- .../control_flow_and_error_handling/index.html | 20 +- .../guide/details_of_the_object_model/index.html | 18 +- .../guide/expressions_and_operators/index.html | 26 +- .../web/javascript/guide/functions/index.html | 26 +- .../javascript/guide/grammar_and_types/index.html | 8 +- files/zh-cn/web/javascript/guide/index.html | 291 +++++---- .../guide/indexed_collections/index.html | 8 +- .../web/javascript/guide/introduction/index.html | 4 +- .../guide/iterators_and_generators/index.html | 2 +- .../zh-cn/web/javascript/guide/modules/index.html | 36 +- .../regular_expressions/assertions/index.html | 8 +- .../character_classes/index.html | 4 +- .../groups_and_ranges/index.html | 8 +- .../guide/regular_expressions/index.html | 4 +- .../unicode_property_escapes/index.html | 12 +- .../web/javascript/guide/using_promises/index.html | 6 +- .../guide/working_with_objects/index.html | 4 +- files/zh-cn/web/javascript/index.html | 8 +- .../inheritance_and_the_prototype_chain/index.html | 6 +- .../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 +- files/zh-cn/web/javascript/typed_arrays/index.html | 4 +- .../web/javascript/guide/functions/index.html | 2 +- 384 files changed, 1487 insertions(+), 10549 deletions(-) diff --git a/files/zh-cn/web/javascript/a_re-introduction_to_javascript/index.html b/files/zh-cn/web/javascript/a_re-introduction_to_javascript/index.html index 1c4b9b7ab0..2e33df8190 100644 --- a/files/zh-cn/web/javascript/a_re-introduction_to_javascript/index.html +++ b/files/zh-cn/web/javascript/a_re-introduction_to_javascript/index.html @@ -18,7 +18,7 @@ translation_of: Web/JavaScript/A_re-introduction_to_JavaScript

几个月后,Microsoft 随 IE 3 发布推出了一个与之基本兼容的语言 JScript。又过了几个月,Netscape 将 JavaScript 提交至 Ecma International(一个欧洲标准化组织), {{Glossary("ECMAScript")}} 标准第一版便在 1997 年诞生了,随后在 1999 年以 ECMAScript 第三版的形式进行了更新,从那之后这个标准没有发生过大的改动。由于委员会在语言特性的讨论上发生分歧,ECMAScript 第四版尚未推出便被废除,但随后于 2009 年 12 月发布的 ECMAScript 第五版引入了第四版草案加入的许多特性。第六版标准已经于 2015 年 6 月发布。

-

注意: 由于这种用法更常见,从这里开始,我们将使用 JavaScript 来指代 ECMAScript 。

+

备注: 由于这种用法更常见,从这里开始,我们将使用 JavaScript 来指代 ECMAScript 。

与大多数编程语言不同,JavaScript 没有输入或输出的概念。它是一个在宿主环境(host environment)下运行的脚本语言,任何与外界沟通的机制都是由宿主环境提供的。浏览器是最常见的宿主环境,但在非常多的其他程序中也包含 JavaScript 解释器,如 Adobe Acrobat、Adobe Photoshop、SVG 图像、Yahoo! 的 Widget 引擎,Node.js 之类的服务器端环境,NoSQL 数据库(如开源的 Apache CouchDB)、嵌入式计算机,以及包括 GNOME (注:GNU/Linux 上最流行的 GUI 之一)在内的桌面环境等等。

@@ -90,7 +90,7 @@ parseInt("010", 10); // 10

一些老版本的浏览器会将首字符为“0”的字符串当做八进制数字,2013 年以前的 JavaScript 实现会返回一个意外的结果:

-
parseInt("010");  //  8
+
parseInt("010");  //  8
 parseInt("0x10"); // 16

这是因为字符串以数字 0 开头,{{jsxref("Global_Objects/parseInt", "parseInt()")}}函数会把这样的字符串视作八进制数字;同理,0x开头的字符串则视为十六进制数字。

@@ -104,7 +104,7 @@ parseInt("0x10"); // 16

一元运算符 + 也可以把数字字符串转换成数值:

-
+ "42";   // 42
+
+ "42";   // 42
 + "010";  // 10
 + "0x10"; // 16
@@ -143,7 +143,9 @@ isFinite("0"); // true // 如果是纯数值类型的检测,则返回 false: Number.isFinite("0"); // false
-
备注: {{jsxref("Global_Objects/parseInt", "parseInt()")}} 和 {{jsxref("Global_Objects/parseFloat", "parseFloat()")}} 函数会尝试逐个解析字符串中的字符,直到遇上一个无法被解析成数字的字符,然后返回该字符前所有数字字符组成的数字。但是运算符 "+"对字符串的转换方式与之不同, 只要字符串含有无法被解析成数字的字符,该字符串就将被转换成 NaN。可分别使用这两种方法解析“10.2abc”这一字符串,并比较得到的结果,来理解这两种方法的区别。
+
+

备注: {{jsxref("Global_Objects/parseInt", "parseInt()")}} 和 {{jsxref("Global_Objects/parseFloat", "parseFloat()")}} 函数会尝试逐个解析字符串中的字符,直到遇上一个无法被解析成数字的字符,然后返回该字符前所有数字字符组成的数字。但是运算符 "+"对字符串的转换方式与之不同, 只要字符串含有无法被解析成数字的字符,该字符串就将被转换成 NaN。可分别使用这两种方法解析“10.2abc”这一字符串,并比较得到的结果,来理解这两种方法的区别。

+

字符串

@@ -190,12 +192,12 @@ Boolean(234); // true

let 语句声明一个块级作用域的本地变量,并且可选的将其初始化为一个值。

-
let a;
+
let a;
 let name = 'Simon';

下面是使用  let 声明变量作用域的例子:

-
// myLetVariable 在这里 *不能* 被引用
+
// myLetVariable 在这里 *不能* 被引用
 
 for (let myLetVariable = 0; myLetVariable < 5; myLetVariable++) {
   // myLetVariable 只能在这里引用
@@ -205,7 +207,7 @@ for (let myLetVariable = 0; myLetVariable < 5; myLetVariable++) {
 
 

const 允许声明一个不可变的常量。这个常量在定义域内总是可见的。

-
const Pi = 3.14; // 设置 Pi 的值
+
const Pi = 3.14; // 设置 Pi 的值
 Pi = 1; // 将会抛出一个错误因为你改变了一个常量的值。

var 是最常见的声明变量的关键字。它没有其他两个关键字的种种限制。这是因为它是传统上在 JavaScript 声明变量的唯一方法。使用 var 声明的变量在它所声明的整个函数都是可见的。

@@ -216,7 +218,7 @@ var name = "simon";

一个使用  var 声明变量的语句块的例子:

-
// myVarVariable在这里 *能* 被引用
+
// myVarVariable在这里 *能* 被引用
 
 for (var myVarVariable = 0; myVarVariable < 5; myVarVariable++) {
   // myVarVariable 整个函数中都能被引用
@@ -302,13 +304,13 @@ do {
 
 

JavaScript 也还包括其他两种重要的 for 循环: for...of

-
for (let value of array) {
+
for (let value of array) {
   // do something with value
 }

for...in

-
for (let property in object) {
+
for (let property in object) {
   // do something with object property
 }
@@ -432,7 +434,7 @@ var name = obj.name;

和:

-
// 括号表示法(bracket notation)
+
// 括号表示法(bracket notation)
 obj['name'] = 'Simon';
 var name = obj['name'];
 // can use a variable to define a key
@@ -446,13 +448,13 @@ obj["for"] = 'Simon'; // 工作正常
 
-

注意:从 ECMAScript 5 开始,预留关键字可以作为对象的属性名(reserved words may be used as object property names "in the buff")。 这意味着当定义对象字面量时不需要用双引号了。参见 ES5 Spec.

+

备注:从 ECMAScript 5 开始,预留关键字可以作为对象的属性名(reserved words may be used as object property names "in the buff")。 这意味着当定义对象字面量时不需要用双引号了。参见 ES5 Spec.

关于对象和原型的详情参见: Object.prototype. 解释对象原型和对象原型链可以参见:继承与原型链

-

注意:从 ECMAScript 2015 开始,对象键可以在创建时使用括号表示法由变量定义。{[phoneType]: 12345} 可以用来替换 var userPhone = {}; userPhone[phoneType] = 12345 .

+

备注:从 ECMAScript 2015 开始,对象键可以在创建时使用括号表示法由变量定义。{[phoneType]: 12345} 可以用来替换 var userPhone = {}; userPhone[phoneType] = 12345 .

数组

@@ -648,8 +650,8 @@ avg(2, 3, 4, 5); // 3.5
avg(2, 3, 4, 5); // 3.5
-
-

在上面这段代码中,所有被传入该函数的参数都被变量 args 所持有。

+
+

备注:在上面这段代码中,所有被传入该函数的参数都被变量 args 所持有。

需要注意的是,无论“剩余参数操作符”被放置到函数声明的哪里,它都会把除了自己之前的所有参数存储起来。比如函数:function avg(firstValue, ...args) 会把传入函数的第一个值存入 firstValue,其他的参数存入 args。这是虽然一个很有用的语言特性,却也会带来新的问题。avg() 函数只接受逗号分开的参数列表 -- 但是如果你想要获取一个数组的平均值怎么办?一种方法是将函数按照如下方式重写:

@@ -671,8 +673,8 @@ avgArray([2, 3, 4, 5]); // 3.5

传给 apply() 的第二个参数是一个数组,它将被当作 avg() 的参数列表使用,至于第一个参数 null,我们将在后面讨论。这也正说明了一个事实——函数也是对象。

-
-

通过使用展开语法,你也可以获得同样的效果。

+
+

备注:通过使用展开语法,你也可以获得同样的效果。

比如说:avg(...numbers)

@@ -735,7 +737,9 @@ b; // 2

自定义对象

-
备注:关于 JavaScript 中面向对象编程更详细的信息,请参考 JavaScript 面向对象简介
+
+

备注:关于 JavaScript 中面向对象编程更详细的信息,请参考 JavaScript 面向对象简介

+

在经典的面向对象语言中,对象是指数据和在这些数据上进行的操作的集合。与 C++ 和 Java 不同,JavaScript 是一种基于原型的编程语言,并没有 class 语句,而是把函数用作类。那么让我们来定义一个人名对象,这个对象包括人的姓和名两个域(field)。名字的表示有两种方法:“名 姓(First Last)”或“姓, 名(Last, First)”。使用我们前面讨论过的函数和对象概念,可以像这样完成定义:

diff --git a/files/zh-cn/web/javascript/about_javascript/index.html b/files/zh-cn/web/javascript/about_javascript/index.html index de4ef3f6e8..0f72075774 100644 --- a/files/zh-cn/web/javascript/about_javascript/index.html +++ b/files/zh-cn/web/javascript/about_javascript/index.html @@ -52,5 +52,6 @@ translation_of: Web/JavaScript/About_JavaScript
已经公布的 JavaScript 标准。
重新认识 JavaScript
JavaScript 指南JavaScript 参考
-
JavaScript®是Oracle于美国和其他国家注册和拥有的商标。
+ +

JavaScript®是Oracle于美国和其他国家注册和拥有的商标。

diff --git a/files/zh-cn/web/javascript/closures/index.html b/files/zh-cn/web/javascript/closures/index.html index 51bba7532c..065ac39a56 100644 --- a/files/zh-cn/web/javascript/closures/index.html +++ b/files/zh-cn/web/javascript/closures/index.html @@ -167,7 +167,7 @@ console.log(Counter.value()); /* logs 1 */

这三个公共函数是共享同一个环境的闭包。多亏 JavaScript 的词法作用域,它们都可以访问 privateCounter 变量和 changeBy 函数。

-

你应该注意到我们定义了一个匿名函数,用于创建一个计数器。我们立即执行了这个匿名函数,并将他的值赋给了变量Counter。我们可以把这个函数储存在另外一个变量makeCounter中,并用他来创建多个计数器。

+

备注:你应该注意到我们定义了一个匿名函数,用于创建一个计数器。我们立即执行了这个匿名函数,并将他的值赋给了变量Counter。我们可以把这个函数储存在另外一个变量makeCounter中,并用他来创建多个计数器。

var makeCounter = function() {
@@ -204,7 +204,7 @@ console.log(Counter2.value()); /* logs 0 */
 

每次调用其中一个计数器时,通过改变这个变量的值,会改变这个闭包的词法环境。然而在一个闭包内对变量的修改,不会影响到另外一个闭包中的变量。

-

以这种方式使用闭包,提供了许多与面向对象编程相关的好处 —— 特别是数据隐藏和封装。

+

备注:以这种方式使用闭包,提供了许多与面向对象编程相关的好处 —— 特别是数据隐藏和封装。

在循环中创建闭包:一个常见错误

diff --git a/files/zh-cn/web/javascript/data_structures/index.html b/files/zh-cn/web/javascript/data_structures/index.html index a28fe01bda..c3a45e0acd 100644 --- a/files/zh-cn/web/javascript/data_structures/index.html +++ b/files/zh-cn/web/javascript/data_structures/index.html @@ -237,7 +237,7 @@ foo = true; // foo is a Boolean now
-

注意:这些特性只有 JavaScript 引擎才用到,因此你不能直接访问它们。所以特性被放在两对方括号中,而不是一对。

+

备注:这些特性只有 JavaScript 引擎才用到,因此你不能直接访问它们。所以特性被放在两对方括号中,而不是一对。

"标准的" 对象, 和函数

diff --git a/files/zh-cn/web/javascript/equality_comparisons_and_sameness/index.html b/files/zh-cn/web/javascript/equality_comparisons_and_sameness/index.html index 502870405e..d36a7e3aad 100644 --- a/files/zh-cn/web/javascript/equality_comparisons_and_sameness/index.html +++ b/files/zh-cn/web/javascript/equality_comparisons_and_sameness/index.html @@ -382,13 +382,12 @@ function attemptMutation(v)

这里是一个会区别对待-0和+0的内置方法和操作符不完全列表:

-

- (一元负)

-
+
- (一元负)

显而易见,对0一元负操作得到-0。但表达式的抽象化可能在你没有意识到得情况下导致-0延续传播。例如当考虑下例时:

-
let stoppingForce = obj.mass * -obj.velocity
+
let stoppingForce = obj.mass * -obj.velocity

如果obj.velocity0 (或计算结果为0), 一个-0就在上处产生并被赋值为stoppingForce的值.

diff --git a/files/zh-cn/web/javascript/eventloop/index.html b/files/zh-cn/web/javascript/eventloop/index.html index bb8dd97448..9720de3eb0 100644 --- a/files/zh-cn/web/javascript/eventloop/index.html +++ b/files/zh-cn/web/javascript/eventloop/index.html @@ -21,7 +21,7 @@ translation_of: Web/JavaScript/EventLoop

可视化描述

-

Stack, heap, queue

+

Stack, heap, queue

@@ -77,7 +77,7 @@ console.log(bar(7)); // 返回 42

下面的例子演示了这个概念(setTimeout 并不会在计时器到期之后直接执行):

-
const s = new Date().getSeconds();
+
const s = new Date().getSeconds();
 
 setTimeout(function() {
   // 输出 "2",表示回调函数并没有在 500 毫秒之后立即执行
diff --git a/files/zh-cn/web/javascript/guide/control_flow_and_error_handling/index.html b/files/zh-cn/web/javascript/guide/control_flow_and_error_handling/index.html
index 4ec8d52e11..cc837aafb0 100644
--- a/files/zh-cn/web/javascript/guide/control_flow_and_error_handling/index.html
+++ b/files/zh-cn/web/javascript/guide/control_flow_and_error_handling/index.html
@@ -95,12 +95,13 @@ alert(x); // 输出的结果为 2
 
 

不建议在条件表达式中使用赋值语句,因为在快速查阅代码时容易把它看成等值比较。例如,不要使用下面的代码:

-
-

   if(x = y){

- -

 /*  语句  */

- -

}

+
+

警告:

+
+  if(x = y){
+    /*  语句  */
+  }
+

如果你需要在条件表达式中使用赋值,通常在赋值语句前后额外添加一对括号。例如: 

@@ -231,9 +232,8 @@ throw {toString: function() { return "I'm an object!"; } };
-
注意:你可以在抛出异常时声明一个对象。那你就可以在catch块中查询到对象的属性。 - - +
+

备注:你可以在抛出异常时声明一个对象。那你就可以在catch块中查询到对象的属性。

// Create an object type UserException
@@ -406,7 +406,7 @@ catch (e) {
  
  • settled:Promise 处于 fulfilled 或 rejected 二者中的任意一个状态, 不会是 pending。
  • -

    +

    通过 XHR 加载图片

    diff --git a/files/zh-cn/web/javascript/guide/details_of_the_object_model/index.html b/files/zh-cn/web/javascript/guide/details_of_the_object_model/index.html index 7df37741c4..17e15ee9bc 100644 --- a/files/zh-cn/web/javascript/guide/details_of_the_object_model/index.html +++ b/files/zh-cn/web/javascript/guide/details_of_the_object_model/index.html @@ -31,8 +31,8 @@ translation_of: Web/JavaScript/Guide/Details_of_the_Object_Model

    JavaScript 大体上与之类似,但并没有专门的类定义,你通过定义构造函数的方式来创建一系列有着特定初始值和方法的对象。任何JavaScript函数都可以被用作构造函数。你也可以使用 new 操作符来创建一个新对象。

    -
    -

    提示:在ES6中引入了 类定义 ,但它实际上是已有的原型继承方式的语法糖而已,并没有引入新的面向对象继承模型。

    +
    +

    备注:在ES6中引入了 类定义 ,但它实际上是已有的原型继承方式的语法糖而已,并没有引入新的面向对象继承模型。

    子类和继承

    @@ -227,7 +227,7 @@ public class Engineer extends WorkerBee {

    使用这些定义,您可以创建这些对象的实例,以获取其属性的默认值。下图说明了如何使用这些 JavaScript 定义创建新对象并显示新对象的属性值。

    -

    提示:实例在基于类的语言中具有特定的技术含义。在这些语言中,一个实例是一个类的单独实例化,与一个类本质上是不同的。在 JavaScript 中,“实例”没有这个技术含义,因为JavaScript在类和实例之间不存在这样的区别。然而,在讨论 JavaScript 时,可以非正式地使用“实例”来表示使用特定构造函数创建的对象。 所以,在这个例子中,你可以非正式地说janeEngineer的一个实例。同样,虽然术语 parent,child,ancestor 和 descendant 在 JavaScript 中没有正式含义;你可以非正式地使用它们来引用原型链中较高或更低的对象。

    +

    备注:实例在基于类的语言中具有特定的技术含义。在这些语言中,一个实例是一个类的单独实例化,与一个类本质上是不同的。在 JavaScript 中,“实例”没有这个技术含义,因为JavaScript在类和实例之间不存在这样的区别。然而,在讨论 JavaScript 时,可以非正式地使用“实例”来表示使用特定构造函数创建的对象。 所以,在这个例子中,你可以非正式地说janeEngineer的一个实例。同样,虽然术语 parent,child,ancestor 和 descendant 在 JavaScript 中没有正式含义;你可以非正式地使用它们来引用原型链中较高或更低的对象。

    用简单的定义创建对象

    @@ -310,14 +310,14 @@ mark.projects = ["navigator"];

    只要 JavaScript 执行了该语句,则 mark 对象也将具有 specialty 属性,其值为 "none"。下图则表示了在 Employee 原型中添加该属性,然后在 Engineer 的原型中重载该属性的效果。

    -


    +


    添加属性

    更灵活的构造器

    到目前为止,本文所展示的构造函数都不能让你在创建新实例时为其制定属性值。其实我们也可以像 Java 一样,为构造器提供参数以初始化实例的属性值。下图展示了一种实现方式。

    -


    +


    Specifying properties in a constructor, take 1

    下面的表格中罗列了这些对象在 Java 和 JavaScript 中的定义。

    @@ -420,7 +420,7 @@ public class Engineer extends WorkerBee {

    JavaScript 的逻辑或操作符(||)会对第一个参数进行判断。如果该参数值运算后结果为真,则操作符返回该值。否则,操作符返回第二个参数的值。因此,这行代码首先检查 name 是否是对name 属性有效的值。如果是,则设置其为 this.name 的值。否则,设置 this.name 的值为空的字符串。尽管这种用法乍看起来有些费解,为了简洁起见,本章将使用这种习惯用法。

    -

    提示:如果调用构造函数时,指定了可以转换为 false 的参数(比如0和空字符串),结果可能出乎调用者意料。此时,将使用默认值(译注:不是指定的参数值 0 和 "")。

    +

    备注:如果调用构造函数时,指定了可以转换为 false 的参数(比如0和空字符串),结果可能出乎调用者意料。此时,将使用默认值(译注:不是指定的参数值 0 和 "")。

    使用这些定义,当创建对象的实例时,可以为本地定义的属性指定值。你可以使用以下语句创建一个新的Engineer

    @@ -440,7 +440,7 @@ jane.machine == "belau"

    到目前为止,构造函数已经能够创建一个普通对象,然后为新对象指定本地的属性和属性值。您还可以通过直接调用原型链上的更高层次对象的构造函数,让构造器添加更多的属性。下图即实现了这一功能。

    -


    +


    Specifying properties in a constructor, take 2

    我们来详细看一下这些定义。这是Engineer构造函数的新定义:

    @@ -636,7 +636,9 @@ chris.__proto__.__proto__.__proto__.__proto__.__proto__ == null; }
    -
    Note: 在上面的实现中,检查对象的类型是否为 "xml" 的目的在于解决新近版本的 JavaScript 中表达 XML 对象的特异之处。如果您想了解其中琐碎细节,可以参考 {{ bug(634150) }}。
    +
    +

    备注: 在上面的实现中,检查对象的类型是否为 "xml" 的目的在于解决新近版本的 JavaScript 中表达 XML 对象的特异之处。如果您想了解其中琐碎细节,可以参考 {{ bug(634150) }}。

    +
    使用上面定义的 instanceOf 函数,这些表达式为真:
    diff --git a/files/zh-cn/web/javascript/guide/expressions_and_operators/index.html b/files/zh-cn/web/javascript/guide/expressions_and_operators/index.html index be9944cc48..20ac54e8b8 100644 --- a/files/zh-cn/web/javascript/guide/expressions_and_operators/index.html +++ b/files/zh-cn/web/javascript/guide/expressions_and_operators/index.html @@ -136,7 +136,7 @@ translation_of: Web/JavaScript/Guide/Expressions_and_Operators

    对于更复杂的赋值,解构赋值语法是一个能从数组或对象对应的数组结构或对象字面量里提取数据的 Javascript 表达式。

    -
    var foo = ["one", "two", "three"];
    +
    var foo = ["one", "two", "three"];
     
     // 不使用解构
     var one   = foo[0];
    @@ -150,7 +150,7 @@ var [one, two, three] = foo;

    比较运算符比较它的操作数并返回一个基于表达式是否为真的逻辑值。操作数可以是数字,字符串,逻辑,对象值。字符串比较是基于标准的字典顺序,使用Unicode值。在多数情况下,如果两个操作数不是相同的类型, JavaScript 会尝试转换它们为恰当的类型来比较。这种行为通常发生在数字作为操作数的比较。类型转换的例外是使用 ===!== 操作符,它们会执行严格的相等和不相等比较。这些运算符不会在检查相等之前转换操作数的类型。下面的表格描述了该示例代码中的各比较运算符

    -
    var var1 = 3;
    +
    var var1 = 3;
     var var2 = 4;
    @@ -217,7 +217,7 @@ var var2 = 4;
    -

    注意: =>) 不是运算符,而是箭头函数的标记符号 。

    +

    备注:=>) 不是运算符,而是箭头函数的标记符号 。

    算术运算符

    @@ -376,12 +376,10 @@ var var2 = 4;
  • 操作数被转换为32bit整數,以位序列(0和1组成)表示.若超過32bits,則取低位32bit,如下所示:
  • -
    -
    -
    Before: 11100110111110100000000000000110000000000001
    -After:              10100000000000000110000000000001
    -
    -
    +
    +  Before: 11100110111110100000000000000110000000000001
    +  After:              10100000000000000110000000000001
    +
    • 第一个操作数的每一位都与第二个操作数的对应位组对: 第一位对应第一位,第二位对应第二位,以此类推.
    • @@ -551,7 +549,7 @@ var n3 = !"Cat"; // !t returns false

      例如,

      -
      console.log("my " + "string"); // console logs the string "my string".
      +
      console.log("my " + "string"); // console logs the string "my string".

      简写操作符 += 也可以用来拼接字符串,例如:

      @@ -719,11 +717,11 @@ void expression

      如下创建了一个超链接文本,当用户单击该文本时,不会有任何效果。

      -
      <a href="javascript:void(0)">Click here to do nothing</a>
      +
      <a href="javascript:void(0)">Click here to do nothing</a>

      下面的代码创建了一个超链接,当用户单击它时,提交一个表单。

      -
      <a href="javascript:void(document.form.submit())">
      +
      <a href="javascript:void(document.form.submit())">
       Click here to submit</a>

      关系操作符

      @@ -913,7 +911,7 @@ this.propertyName

      分组操作符()控制了表达式中计算的优先级. 举例来说, 你可以改变先乘除后加减的顺序,转而先计算加法。

      -
      var a = 1;
      +
      var a = 1;
       var b = 2;
       var c = 3;
       
      @@ -941,7 +939,7 @@ a * c + b * c // 9

      Comprehensions特性被许多编程语言所采用,该特性能够使你快速地通过一个已有的数组来创建出一个新的数组,比如:

      -
      [for (i of [ 1, 2, 3 ]) i*i ];
      +
      [for (i of [ 1, 2, 3 ]) i*i ];
       // [ 1, 4, 9 ]
       
       var abc = [ "A", "B", "C" ];
      diff --git a/files/zh-cn/web/javascript/guide/functions/index.html b/files/zh-cn/web/javascript/guide/functions/index.html
      index 73a1efbdc4..e37f71e8a8 100644
      --- a/files/zh-cn/web/javascript/guide/functions/index.html
      +++ b/files/zh-cn/web/javascript/guide/functions/index.html
      @@ -85,7 +85,7 @@ console.log(factorial(3));
       
       

      下面的代码:

      -
      function map(f, a) {
      +
      function map(f, a) {
         let result = []; // 创建一个数组
         let i; // 声明一个值,用来循环
         for (i = 0; i != a.length; i++)
      @@ -133,10 +133,10 @@ function square(n) { return n*n }
       

      函数域是指函数声明时的所在的地方,或者函数在顶层被声明时指整个程序。

      -

      提示:注意只有使用如上的语法形式(即 function funcName(){})才可以。而下面的代码是无效的。就是说,函数提升仅适用于函数声明,而不适用于函数表达式。

      +

      备注:注意只有使用如上的语法形式(即 function funcName(){})才可以。而下面的代码是无效的。就是说,函数提升仅适用于函数声明,而不适用于函数表达式。

      -
      console.log(square); // square is hoisted with an initial value undefined.
      +
      console.log(square); // square is hoisted with an initial value undefined.
       console.log(square(5)); // Uncaught TypeError: square is not a function
       const square = function (n) {
         return n * n;
      @@ -167,7 +167,7 @@ e = factorial(5); // 120赋值给e
       
       

      还有其它的方式来调用函数。常见的一些情形是某些地方需要动态调用函数,或者函数的实参数量是变化的,或者调用函数的上下文需要指定为在运行时确定的特定对象。显然,函数本身就是对象,因此这些对象也有方法(参考{{jsxref("Function")}} )。作为此中情形之一,{{jsxref("Function.apply", "apply()")}}方法可以实现这些目的。

      -

      函数作用域

      +

      函数作用域

      在函数内定义的变量不能在函数之外的任何地方访问,因为变量仅仅在该函数的域的内部有定义。相对应的,一个函数可以访问定义在其范围内的任何变量和函数。换言之,定义在全局域中的函数可以访问所有定义在全局域中的变量。在另一个函数中定义的函数也可以访问在其父函数中定义的所有变量和父函数有权访问的任何其他变量。

      @@ -442,8 +442,8 @@ pet.getName(); // Oliver getCode(); // Returns the secret code
      -
      -

      尽管有上述优点,使用闭包时仍然要小心避免一些陷阱。如果一个闭包的函数定义了一个和外部函数的某个变量名称相同的变量,那么这个闭包将无法引用外部函数的这个变量。

      +
      +

      备注:尽管有上述优点,使用闭包时仍然要小心避免一些陷阱。如果一个闭包的函数定义了一个和外部函数的某个变量名称相同的变量,那么这个闭包将无法引用外部函数的这个变量。

      var createPet = function(name) {  // Outer function defines a variable called "name"
         return {
      @@ -468,7 +468,7 @@ getCode();    // Returns the secret code
       
       

      例如,设想有一个用来连接字符串的函数。唯一事先确定的参数是在连接后的字符串中用来分隔各个连接部分的字符(译注:比如例子里的分号“;”)。该函数定义如下:

      -
      function myConcat(separator) {
      +
      function myConcat(separator) {
          var result = ''; // 把值初始化成一个字符串,这样就可以用来保存字符串了!!
          var i;
          // iterate through arguments
      @@ -490,7 +490,9 @@ myConcat("; ", "elephant", "giraffe", "lion", "cheetah");
       myConcat(". ", "sage", "basil", "oregano", "pepper", "parsley");
       
      -
      提示:arguments变量只是 类数组对象“,并不是一个数组。称其为类数组对象是说它有一个索引编号和length属性。尽管如此,它并不拥有全部的Array对象的操作方法。
      +
      +

      备注:arguments变量只是 类数组对象“,并不是一个数组。称其为类数组对象是说它有一个索引编号和length属性。尽管如此,它并不拥有全部的Array对象的操作方法。

      +

      更多信息请阅读JavaScript参考里的{{jsxref("Function")}}一文。

      @@ -544,7 +546,7 @@ console.log(arr); // [2, 4, 6]

      在一些函数模式中,更简洁的函数很受欢迎。对比一下:

      -
      var a = [
      +
      var a = [
         "Hydrogen",
         "Helium",
         "Lithium",
      @@ -563,7 +565,7 @@ console.log(a3); // logs [ 8, 6, 7, 9 ]

      在箭头函数出现之前,每一个新函数都重新定义了自己的 this 值(在构造函数中是一个新的对象;在严格模式下是未定义的;在作为“对象方法”调用的函数中指向这个对象;等等)。以面向对象的编程风格,这样着实有点恼人。

      -
      function Person() {
      +
      function Person() {
         // 构造函数Person()将`this`定义为自身
         this.age = 0;
       
      @@ -579,7 +581,7 @@ var p = new Person();

      在ECMAScript 3/5里,通过把this的值赋值给一个变量可以修复这个问题。

      -
      function Person() {
      +
      function Person() {
         var self = this; // 有的人习惯用`that`而不是`self`,
                          // 无论你选择哪一种方式,请保持前后代码的一致性
         self.age = 0;
      @@ -594,7 +596,7 @@ var p = new Person();

      箭头函数捕捉闭包上下文的this值,所以下面的代码工作正常。

      -
      function Person(){
      +
      function Person(){
         this.age = 0;
       
         setInterval(() => {
      diff --git a/files/zh-cn/web/javascript/guide/grammar_and_types/index.html b/files/zh-cn/web/javascript/guide/grammar_and_types/index.html
      index 7fb7d70567..4ac46cbc48 100644
      --- a/files/zh-cn/web/javascript/guide/grammar_and_types/index.html
      +++ b/files/zh-cn/web/javascript/guide/grammar_and_types/index.html
      @@ -357,7 +357,7 @@ console.log(a.length); // 1
       console.log(a[0]); // 3
      -

      注意 这里的数组字面值也是一种对象初始化器。参考对象初始化器的使用

      +

      备注: 这里的数组字面值也是一种对象初始化器。参考对象初始化器的使用

      若在顶层(全局)脚本里用字面值创建数组,JavaScript语言将会在每次对包含该数组字面值的表达式求值时解释该数组。另一方面,在函数中使用的数组,将在每次调用函数时都会被创建一次。

      @@ -376,7 +376,7 @@ console.log(a[0]); // 3

      如果你在元素列表的尾部添加了一个逗号,它将会被忽略。在下面的例子中,数组的长度是3,并不存在myList[3]这个元素(译注:这是指数组的第4个元素噢,作者是在帮大家复习数组元素的排序命名方法)。元素列表中其它所有的逗号都表示一个新元素(的开始)。

      -

      注意:尾部的逗号在早期版本的浏览器中会产生错误,因而编程时的最佳实践方式就是移除它们。

      +

      备注:尾部的逗号在早期版本的浏览器中会产生错误,因而编程时的最佳实践方式就是移除它们。

      (译注:而“现代”的浏览器似乎鼓励这种方式,这也很好解释原因。尾部逗号可以减少向数组的最后添加元素时,因为忘记为这最后一个元素加逗号 所造成的错误。)

      @@ -495,7 +495,7 @@ console.log(unusualPropertyNames["!"]); // Bang!

      在ES2015,对象字面值扩展支持在创建时设置原型,简写了 foo: foo 形式的属性赋值,方法定义,支持父方法调用,以及使用表达式动态计算属性名。总之,这些也使对象字面值和类声明更加紧密地联系起来,让基于对象的设计从这些便利中更加受益。

      -
      var obj = {
      +
      var obj = {
           // __proto__
           __proto__: theProtoObj,
           // Shorthand for ‘handler: handler’
      @@ -523,7 +523,7 @@ console.log(foo["2"]); // two

      一个正则表达式是字符被斜线(译注:正斜杠“/”)围成的表达式。下面是一个正则表达式文字的一个例子。

      -
      var re = /ab+c/;
      +
      var re = /ab+c/;

      字符串字面量 (String literals)

      diff --git a/files/zh-cn/web/javascript/guide/index.html b/files/zh-cn/web/javascript/guide/index.html index 7917823730..419d7d24e7 100644 --- a/files/zh-cn/web/javascript/guide/index.html +++ b/files/zh-cn/web/javascript/guide/index.html @@ -10,126 +10,189 @@ translation_of: Web/JavaScript/Guide

      JavaScript 指南向你介绍如何使用 JavaScript,并且给出了语言概述。如果你需要了解某些语言特性的详细信息,请参阅 JavaScript 参考

      -

      章节

      - -

      本指南分为以下章节:

      - -
      -

      注意: 以上代码,数组长度(arrayLength)必须为一个数字(Number)。否则,将会创建一个只有单个(所输入的)元素的数组。 调用 arr.length 会返回数组长度,但是数组实际上包含了空的(undefined)元素。 因此在数组上使用 for...in 循环,将不会返回任何的值 。

      +

      备注:以上代码,数组长度(arrayLength)必须为一个数字(Number)。否则,将会创建一个只有单个(所输入的)元素的数组。 调用 arr.length 会返回数组长度,但是数组实际上包含了空的(undefined)元素。 因此在数组上使用 for...in 循环,将不会返回任何的值 。

      除了如上所示创建新定义的变量,数组(array)也可以作为一个属性(property)分配给一个新的或者已存在的对象(object):

      @@ -82,7 +82,7 @@ emp[2] = "August West";
      -

      注意:如果你在以上代码中给数组操作符的是一个非整形数值,那么将作为一个代表数组的对象的属性(property)创建,而非作为数组的元素。

      +

      备注:如果你在以上代码中给数组操作符的是一个非整形数值,那么将作为一个代表数组的对象的属性(property)创建,而非作为数组的元素。

      var arr = [];
      @@ -107,7 +107,7 @@ var myArray = ["Mango", "Apple", "Orange"]
       

      你可以用 myArray[0]引用第一个元素,myArray[1]引用第二个元素。元素的索引是从0开始的。

      -

      注意:数组操作符(方括号 [ ])也可以用来访问数组的属性(在 JavaScript 中,数组也是对象)。例如:

      +

      备注:数组操作符(方括号 [ ])也可以用来访问数组的属性(在 JavaScript 中,数组也是对象)。例如:

      var arr = ["one", "two", "three"];
      @@ -461,7 +461,7 @@ var interpolatedZeros = [c+'0' for (c of str) ].join(''); // 'a0b0c0d0e0f0'
       
       

      为了实现最大的灵活性和效率,JavaScript类型数组被分解为缓冲(Buffer)和视图(views)。缓冲(由{{jsxref("ArrayBuffer")}} 实现)是代表数据块的对象,它没有格式可言,并没有提供任何机制来访问其内容。为了访问包含在缓冲区中的内存,您需要使用视图。视图提供了一个上下文,即数据类型、起始偏移量和元素数,这些元素将数据转换为实际类型数组。

      -

      Typed arrays in an ArrayBuffer

      +

      Typed arrays in an ArrayBuffer

      ArrayBuffer

      diff --git a/files/zh-cn/web/javascript/guide/introduction/index.html b/files/zh-cn/web/javascript/guide/introduction/index.html index f6a85d1e2d..36bcfc6639 100644 --- a/files/zh-cn/web/javascript/guide/introduction/index.html +++ b/files/zh-cn/web/javascript/guide/introduction/index.html @@ -111,7 +111,7 @@ translation_of: Web/JavaScript/Guide/Introduction

      在火狐浏览器菜单栏的 “工具" => "Web开发者" => "Web控制台" 可以打开控制台( 在Windows和Linux上Ctrl+Shift+K ,Mac上Cmd+Option+K) ,它会如期出现在浏览器窗口的底部。如图,最下一行就是可以执行输入的命令行,面板上可以显示执行结果:

      -

      +

      控制台的工作方式与eval完全相同:返回最后输入的表达式。为了简单起见,可以想象每次输入到控制台的东西实际上都被 console.log 所包围。

      @@ -125,7 +125,7 @@ translation_of: Web/JavaScript/Guide/Introduction

      如果你选择显示,草稿纸中的代码会在浏览器中执行,并在内容后面以注释的形式插入返回的结果:

      -

      +

      Hello world

      diff --git a/files/zh-cn/web/javascript/guide/iterators_and_generators/index.html b/files/zh-cn/web/javascript/guide/iterators_and_generators/index.html index 1694adbd61..9e5bbe3cbd 100644 --- a/files/zh-cn/web/javascript/guide/iterators_and_generators/index.html +++ b/files/zh-cn/web/javascript/guide/iterators_and_generators/index.html @@ -70,7 +70,7 @@ console.log("Iterated over sequence of size: ", result.value); // 5
      -

      反射性地知道特定对象是否是迭代器是不可能的。 如果您需要这样做,请使用 Iterables.

      +

      备注:反射性地知道特定对象是否是迭代器是不可能的。 如果您需要这样做,请使用 Iterables.

      生成器函数

      diff --git a/files/zh-cn/web/javascript/guide/modules/index.html b/files/zh-cn/web/javascript/guide/modules/index.html index 3ad682563c..e3db44e9a0 100644 --- a/files/zh-cn/web/javascript/guide/modules/index.html +++ b/files/zh-cn/web/javascript/guide/modules/index.html @@ -39,8 +39,8 @@ translation_of: Web/JavaScript/Guide/Modules

      这的确有点简单,但是保持足够简单能够清晰地演示模块。

      -
      -

      Note: 如果你想去下载这个例子在本地运行,你需要通过本地 web 服务器去运行。

      +
      +

      备注:如果你想去下载这个例子在本地运行,你需要通过本地web 服务器去运行。

      基本的示例文件的结构

      @@ -53,8 +53,8 @@ modules/ canvas.mjs square.mjs
      -
      -

      Note: 在这个指南的全部示例项目的文件结构是基本相同的; 需要熟悉上面的内容

      +
      +

      备注:在这个指南的全部示例项目的文件结构是基本相同的; 需要熟悉上面的内容

      modules 目录下的两个模块的描述如下:

      @@ -77,8 +77,8 @@ modules/
    -
    -

    Note: 在原生JavaScript模块中, 扩展名 .mjs 非常重要,因为使用 MIME-type 为javascript/esm 来导入文件(其他的JavaScript 兼容 MIME-type 像 application/javascript 也可以), 它避免了严格的 MIME 类型检查错误,像 "The server responded with a non-JavaScript MIME type". 除此之外,  .mjs 的扩展名很明了(比如这个就是一个模块,而不是一个传统 JavaScript文件),还能够和其他工具互相适用. 看这个 Google's note for further details.

    +
    +

    备注:在原生JavaScript模块中, 扩展名 .mjs 非常重要,因为使用 MIME-type 为javascript/esm 来导入文件(其他的JavaScript 兼容 MIME-type 像 application/javascript 也可以), 它避免了严格的 MIME 类型检查错误,像 "The server responded with a non-JavaScript MIME type". 除此之外,  .mjs 的扩展名很明了(比如这个就是一个模块,而不是一个传统 JavaScript文件),还能够和其他工具互相适用. 看这个 Google's note for further details.

    .mjs 与 .js

    @@ -151,8 +151,8 @@ export function draw(ctx, length, x, y, color) {

    你可以在main.mjs中看到这些。

    -
    -

    Note:在一些模块系统中你可以忽略文件扩展名(比如'/model/squre' .这在原生JavaScript 模块系统中不工作。此外,记住你需要包含最前面的正斜杠。   (修订版 1889482)

    +
    +

    备注:在一些模块系统中你可以忽略文件扩展名(比如'/model/squre' .这在原生JavaScript 模块系统中不工作。此外,记住你需要包含最前面的正斜杠。 (修订版 1889482)

    因为你导入了这些功能到你的脚本文件,你可以像定义在相同的文件中的一样去使用它。下面展示的是在 main.mjs 中的import 语句下面的内容。

    @@ -177,8 +177,8 @@ reportPerimeter(square1.length, reportList);

    你只能在模块内部使用 importexport 语句 ;不是普通脚本文件。

    -
    -

    Note: 您还可以将模块导入内部脚本,只要包含 type="module",例如 <script type="module"> //include script here </script>.

    +
    +

    备注:您还可以将模块导入内部脚本,只要包含 type="module",例如 <script type="module"> //include script here </script>.

    其他模块与标准脚本的不同

    @@ -216,8 +216,8 @@ reportPerimeter(square1.length, reportList);
    import {default as randomSquare} from './modules/square.mjs';
    -
    -

    Note: 重命名导出项的as语法在下面的{{anch("Renaming imports and exports")}}部分中进行了说明。

    +
    +

    备注:重命名导出项的as语法在下面的{{anch("Renaming imports and exports")}}部分中进行了说明。

    避免命名冲突

    @@ -362,8 +362,8 @@ square1.reportPerimeter();
    export * from 'x.mjs'
     export { name } from 'x.mjs'
    -
    -

    Note: 这实际上是导入后跟导出的简写,即“我导入模块x.mjs,然后重新导出部分或全部导出”。

    +
    +

    备注:这实际上是导入后跟导出的简写,即“我导入模块x.mjs,然后重新导出部分或全部导出”。

    有关示例,请参阅我们的module-aggregation。 在这个例子中(基于我们之前的类示例),我们有一个名为shapes.mjs的额外模块,它将circle.mjssquare.mjsriangle.mjs中的所有功能聚合在一起。 我们还将子模块移动到名为shapes的modules目录中的子目录中。 所以模块结构现在是这样的:

    @@ -388,12 +388,12 @@ export { Circle } from '/js-examples/modules/module-aggregation/modules/shapes/c

    它们从各个子模块中获取导出,并有效地从shapes.mjs模块中获取它们。

    -
    -

    Note: 即使shapes.mjs文件位于 modules 目录中,我们仍然需要相对于模块根目录编写这些URL,因此需要/modules/。 这是使用JavaScript模块时混淆的常见原因。

    +
    +

    备注:即使shapes.mjs文件位于modules目录中,我们仍然需要相对于模块根目录编写这些URL,因此需要/modules/。 这是使用JavaScript模块时混淆的常见原因。

    -
    -

    Note: shapes.mjs中引用的导出基本上通过文件重定向,并且实际上并不存在,因此您将无法在同一文件中编写任何有用的相关代码。

    +
    +

    备注:shapes.mjs中引用的导出基本上通过文件重定向,并且实际上并不存在,因此您将无法在同一文件中编写任何有用的相关代码。

    所以现在在main.mjs 文件中,我们可以通过替换来访问所有三个模块类

    diff --git a/files/zh-cn/web/javascript/guide/regular_expressions/assertions/index.html b/files/zh-cn/web/javascript/guide/regular_expressions/assertions/index.html index 0d3757acd6..783c2985e0 100644 --- a/files/zh-cn/web/javascript/guide/regular_expressions/assertions/index.html +++ b/files/zh-cn/web/javascript/guide/regular_expressions/assertions/index.html @@ -32,8 +32,8 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions/Assertions

    匹配输入的开头。如果多行模式设为 true,^ 在换行符后也能立即匹配,比如 /^A/ 匹配不了 "an A" 里面的 "A",但是可以匹配 "An A" 里面第一个 "A"。

    -
    -

    ^ 出现在集合或范围开头时的含义与此不同(参见 group)。

    +
    +

    备注:^ 出现在集合或范围开头时的含义与此不同(参见 group)。

    @@ -71,8 +71,8 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions/Assertions

    其他断言 

    -
    -

    提示:字符也可用作量词

    +
    +

    备注:字符也可用作量词

    diff --git a/files/zh-cn/web/javascript/guide/regular_expressions/character_classes/index.html b/files/zh-cn/web/javascript/guide/regular_expressions/character_classes/index.html index 84bf4e0090..09cf23daa0 100644 --- a/files/zh-cn/web/javascript/guide/regular_expressions/character_classes/index.html +++ b/files/zh-cn/web/javascript/guide/regular_expressions/character_classes/index.html @@ -130,8 +130,8 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions/Character_Classes
  • For characters that are usually treated specially, indicates that the next character is not special and should be interpreted literally. For example, "*" is a special character that means 0 or more occurrences of the preceding character should be matched; for example, /a*/ means match 0 or more "a"s. To match * literally, precede it with a backslash; for example, /a\*/ matches "a*".
  • -
    -

    To match this character literally, escape it with itself. In other words to search for \ use /\\/.

    +
    +

    备注:To match this character literally, escape it with itself. In other words to search for \ use /\\/.

    diff --git a/files/zh-cn/web/javascript/guide/regular_expressions/groups_and_ranges/index.html b/files/zh-cn/web/javascript/guide/regular_expressions/groups_and_ranges/index.html index ac6334b3df..f0045774ff 100644 --- a/files/zh-cn/web/javascript/guide/regular_expressions/groups_and_ranges/index.html +++ b/files/zh-cn/web/javascript/guide/regular_expressions/groups_and_ranges/index.html @@ -46,8 +46,8 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions/Groups_and_Ranges
    @@ -125,8 +125,8 @@ do { // Hellow 李 雷 // Hellow 韩 梅梅 -
    -

    Note: 并不是所有的浏览器都支持这个功能; 参考兼容表: compatibility table.

    +
    +

    备注: 并不是所有的浏览器都支持这个功能; 参考兼容表: compatibility table.

    技术指标

    diff --git a/files/zh-cn/web/javascript/guide/regular_expressions/index.html b/files/zh-cn/web/javascript/guide/regular_expressions/index.html index 945081c966..b8f02f1a9b 100644 --- a/files/zh-cn/web/javascript/guide/regular_expressions/index.html +++ b/files/zh-cn/web/javascript/guide/regular_expressions/index.html @@ -245,7 +245,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions /\w\b\w/将不能匹配任何字符串,因为在一个单词中间的字符永远也不可能同时满足没有“字”字符跟随和有“字”字符跟随两种情况。

    -

    注意: JavaScript的正则表达式引擎将特定的字符集定义为“字”字符。不在该集合中的任何字符都被认为是一个断词。这组字符相当有限:它只包括大写和小写的罗马字母,十进制数字和下划线字符。不幸的是,重要的字符,例如“é”或“ü”,被视为断词。

    +

    备注: JavaScript的正则表达式引擎将特定的字符集定义为“字”字符。不在该集合中的任何字符都被认为是一个断词。这组字符相当有限:它只包括大写和小写的罗马字母,十进制数字和下划线字符。不幸的是,重要的字符,例如“é”或“ü”,被视为断词。

    @@ -543,7 +543,7 @@ console.log("The value of lastIndex is " + /d(b+)d/g.lastIndex);

    当发生/d(b+)d/g使用两个不同状态的正则表达式对象,lastIndex属性会得到不同的值。如果你需要访问一个正则表达式的属性,则需要创建一个对象初始化生成器,你应该首先把它赋值给一个变量。

    -

    使用括号的子字符串匹配

    +

    使用括号的子字符串匹配

    一个正则表达式模式使用括号,将导致相应的子匹配被记住。例如,/a(b)c /可以匹配字符串“abc”,并且记得“b”。回调这些括号中匹配的子串,使用数组元素[1],……[n]。

    diff --git a/files/zh-cn/web/javascript/guide/regular_expressions/unicode_property_escapes/index.html b/files/zh-cn/web/javascript/guide/regular_expressions/unicode_property_escapes/index.html index cf8a7207b6..64254c284c 100644 --- a/files/zh-cn/web/javascript/guide/regular_expressions/unicode_property_escapes/index.html +++ b/files/zh-cn/web/javascript/guide/regular_expressions/unicode_property_escapes/index.html @@ -9,12 +9,12 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escape
    {{EmbedInteractiveExample("pages/js/regexp-unicode-property-escapes.html", "taller")}}
    -
    -

    Note: 使用 Unicode 属性转义依靠 \u 标识\u 表示该字符串被视为一串 Unicode 代码点。参考 RegExp.prototype.nicode.

    +
    +

    备注:使用 Unicode 属性转义依靠 \u 标识\u 表示该字符串被视为一串 Unicode 代码点。参考 RegExp.prototype.nicode.

    -
    -

    Note: 某些 Unicode 属性比字符类(如 \w 只匹配拉丁字母 a 到 z)包含更多的字符  ,但后者浏览器兼容性更好 (截至2020 一月).

    +
    +

    备注: 某些 Unicode 属性比字符类(如 \w 只匹配拉丁字母 a 到 z)包含更多的字符  ,但后者浏览器兼容性更好 (截至2020 一月).

    句法

    @@ -48,8 +48,8 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions/Unicode_Property_Escape
    很多值有同名或简写(e.g. 对应着 General_Category 属性名的属性值 Decimal_Number 可以写作 Nd, digit, 或 Decimal_Number). 大多数属性值的 Unicode属性名 和等号可以省去。如果想明确某 Unicode属性名,必须给出它的值。
    -
    -

    Note: 因为可使用的属性和值太多,这里不一一赘述,仅提供几个例子。

    +
    +

    备注: 因为可使用的属性和值太多,这里不一一赘述,仅提供几个例子。

    基本原理

    diff --git a/files/zh-cn/web/javascript/guide/using_promises/index.html b/files/zh-cn/web/javascript/guide/using_promises/index.html index 22a0163216..5d7c65bf68 100644 --- a/files/zh-cn/web/javascript/guide/using_promises/index.html +++ b/files/zh-cn/web/javascript/guide/using_promises/index.html @@ -36,13 +36,13 @@ createAudioFileAsync(audioSettings, successCallback, failureCallback)

    如果函数 createAudioFileAsync() 被重写为返回 Promise 的形式,那么我们可以像下面这样简单地调用它:

    -
    const promise = createAudioFileAsync(audioSettings);
    +
    const promise = createAudioFileAsync(audioSettings);
     promise.then(successCallback, failureCallback);
     

    或者简写为:

    -
    createAudioFileAsync(audioSettings).then(successCallback, failureCallback);
    +
    createAudioFileAsync(audioSettings).then(successCallback, failureCallback);
     

    我们把这个称为 异步函数调用,这种形式有若干优点,下面我们将会逐一讨论。

    @@ -65,7 +65,7 @@ promise.then(successCallback, failureCallback);

    见证奇迹的时刻:then() 函数会返回一个和原来不同的新的 Promise

    -
    const promise = doSomething();
    +
    const promise = doSomething();
     const promise2 = promise.then(successCallback, failureCallback);
     
    diff --git a/files/zh-cn/web/javascript/guide/working_with_objects/index.html b/files/zh-cn/web/javascript/guide/working_with_objects/index.html index dbdc3294a6..3cde5dd29d 100644 --- a/files/zh-cn/web/javascript/guide/working_with_objects/index.html +++ b/files/zh-cn/web/javascript/guide/working_with_objects/index.html @@ -75,7 +75,7 @@ console.log(myObj); myCar[propertyName] = "Mustang";
    -

    你可以在  for...in 语句中使用方括号标记以枚举一个对象的所有属性。为了展示它如何工作,下面的函数当你将对象及其名称作为参数传入时,显示对象的属性:

    +

    你可以在  for...in 语句中使用方括号标记以枚举一个对象的所有属性。为了展示它如何工作,下面的函数当你将对象及其名称作为参数传入时,显示对象的属性:

    function showProps(obj, objName) {
       var result = "";
    @@ -491,7 +491,7 @@ fruit === fruitbear // return false
     
    -

    注意: "===" 运算符用来检查数值是否相等: 1 === "1"返回false,而1 == "1" 返回true

    +

    备注: "===" 运算符用来检查数值是否相等: 1 === "1"返回false,而1 == "1" 返回true

    // 两个变量, 同一个对象
    diff --git a/files/zh-cn/web/javascript/index.html b/files/zh-cn/web/javascript/index.html
    index 025e203963..959237a0ae 100644
    --- a/files/zh-cn/web/javascript/index.html
    +++ b/files/zh-cn/web/javascript/index.html
    @@ -18,8 +18,6 @@ translation_of: Web/JavaScript
     
     

    不要将 JavaScript 与 Java编程语言 混淆。虽然“Java”和“JavaScript”都是 Oracle 公司在美国和其他国家注册(或未注册)的商标,但是这两门语言在语法、语义与用途方面有很大不同。

    -
    -

    教程

    通过使用指南和教程来学习如何用JavaScript语言编程。

    @@ -73,9 +71,7 @@ translation_of: Web/JavaScript
    并发模型以及事件循环
    JavaScript 具有基于“事件循环”的并发模型。
    -
    -

    参考

    浏览完整的 JavaScript 参考文档。

    @@ -102,7 +98,7 @@ translation_of: Web/JavaScript
    允许您快速测试 JavaScript 代码片段。
    TogetherJS
    -

    添加 TogetherJS 到您的网站,让用户实时互助,协作更简单。

    +

    添加 TogetherJS 到您的网站,让用户实时互助,协作更简单。

    Stack Overflow
    你可以在 StackOverflow 查看或者发布带有 JavaScript 标签的问题。
    @@ -117,5 +113,3 @@ translation_of: Web/JavaScript

    JS Bin 是一种开源的协作式的web 开发调试工具。

    -
    -
    diff --git a/files/zh-cn/web/javascript/inheritance_and_the_prototype_chain/index.html b/files/zh-cn/web/javascript/inheritance_and_the_prototype_chain/index.html index 31f0522871..b9ba6dc992 100644 --- a/files/zh-cn/web/javascript/inheritance_and_the_prototype_chain/index.html +++ b/files/zh-cn/web/javascript/inheritance_and_the_prototype_chain/index.html @@ -32,7 +32,7 @@ translation_of: Web/JavaScript/Inheritance_and_the_prototype_chain

    JavaScript 对象是动态的属性“包”(指其自己的属性)。JavaScript 对象有一个指向一个原型对象的链。当试图访问一个对象的属性时,它不仅仅在该对象上搜寻,还会搜寻该对象的原型,以及该对象的原型的原型,依次层层向上搜索,直到找到一个名字匹配的属性或到达原型链的末尾。

    -

    遵循ECMAScript标准,someObject.[[Prototype]] 符号是用于指向 someObject 的原型。从 ECMAScript 6 开始,[[Prototype]] 可以通过 {{jsxref("Object.getPrototypeOf()")}} 和 {{jsxref("Object.setPrototypeOf()")}} 访问器来访问。这个等同于 JavaScript 的非标准但许多浏览器实现的属性 __proto__

    +

    备注:遵循ECMAScript标准,someObject.[[Prototype]] 符号是用于指向 someObject 的原型。从 ECMAScript 6 开始,[[Prototype]] 可以通过 {{jsxref("Object.getPrototypeOf()")}} 和 {{jsxref("Object.setPrototypeOf()")}} 访问器来访问。这个等同于 JavaScript 的非标准但许多浏览器实现的属性 __proto__

    但它不应该与构造函数 funcprototype 属性相混淆。被构造函数创建的实例对象的 [[Prototype]] 指向 funcprototype 属性。Object.prototype 属性表示 {{jsxref("Object")}} 的原型对象。

    @@ -533,8 +533,8 @@ Foo.call(o);

    在使用原型继承编写复杂代码之前,理解原型继承模型是至关重要的。此外,请注意代码中原型链的长度,并在必要时将其分解,以避免可能的性能问题。此外,原生原型不应该被扩展,除非它是为了与新的 JavaScript 特性兼容。

    -
    -

    译者注:在英文原版中,以下内容已被移除。保留仅作参考。

    +
    +

    备注:在英文原版中,以下内容已被移除。保留仅作参考。

    示例

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

    - -
    -

    一个否定的或被补充的字符集。也就是说,它匹配任何没有包含在括号中的字符。可以通过使用连字符来指定字符范围,但是如果连字符作为方括号中的第一个或最后一个字符出现,那么它将被视为作为普通字符包含在字符集中。例如,[^abc]和[^a-c]一样。它们最初匹配“bacon”中的“o”和“chop”中的“h”。

    -
    -

     ^ 字符也可以表示   输入的起始

    +
    +

    备注: ^ 字符也可以表示   输入的起始

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

    相关链接