diff --git a/files/ja/_redirects.txt b/files/ja/_redirects.txt index d87a2a01366c87..6fab820d5fff73 100644 --- a/files/ja/_redirects.txt +++ b/files/ja/_redirects.txt @@ -993,14 +993,14 @@ /ja/docs/DOM/window.resizeTo /ja/docs/Web/API/Window/resizeTo /ja/docs/DOM/window.screen /ja/docs/Web/API/Window/screen /ja/docs/DOM/window.screen.availHeight /ja/docs/Web/API/Screen/availHeight -/ja/docs/DOM/window.screen.availLeft /ja/docs/Web/API/Screen/availLeft -/ja/docs/DOM/window.screen.availTop /ja/docs/Web/API/Screen/availTop +/ja/docs/DOM/window.screen.availLeft /ja/docs/Web/API/ScreenDetailed/availLeft +/ja/docs/DOM/window.screen.availTop /ja/docs/Web/API/ScreenDetailed/availTop /ja/docs/DOM/window.screen.availWidth /ja/docs/Web/API/Screen/availWidth /ja/docs/DOM/window.screen.colorDepth /ja/docs/Web/API/Screen/colorDepth /ja/docs/DOM/window.screen.height /ja/docs/Web/API/Screen/height -/ja/docs/DOM/window.screen.left /ja/docs/Web/API/Screen/left +/ja/docs/DOM/window.screen.left /ja/docs/Web/API/ScreenDetailed/left /ja/docs/DOM/window.screen.pixelDepth /ja/docs/Web/API/Screen/pixelDepth -/ja/docs/DOM/window.screen.top /ja/docs/Web/API/Screen/top +/ja/docs/DOM/window.screen.top /ja/docs/Web/API/ScreenDetailed/top /ja/docs/DOM/window.screen.width /ja/docs/Web/API/Screen/width /ja/docs/DOM/window.screenX /ja/docs/Web/API/Window/screenX /ja/docs/DOM/window.screenY /ja/docs/Web/API/Window/screenY @@ -1203,14 +1203,14 @@ /ja/docs/DOM:window.resizeTo /ja/docs/Web/API/Window/resizeTo /ja/docs/DOM:window.screen /ja/docs/Web/API/Window/screen /ja/docs/DOM:window.screen.availHeight /ja/docs/Web/API/Screen/availHeight -/ja/docs/DOM:window.screen.availLeft /ja/docs/Web/API/Screen/availLeft -/ja/docs/DOM:window.screen.availTop /ja/docs/Web/API/Screen/availTop +/ja/docs/DOM:window.screen.availLeft /ja/docs/Web/API/ScreenDetailed/availLeft +/ja/docs/DOM:window.screen.availTop /ja/docs/Web/API/ScreenDetailed/availTop /ja/docs/DOM:window.screen.availWidth /ja/docs/Web/API/Screen/availWidth /ja/docs/DOM:window.screen.colorDepth /ja/docs/Web/API/Screen/colorDepth /ja/docs/DOM:window.screen.height /ja/docs/Web/API/Screen/height -/ja/docs/DOM:window.screen.left /ja/docs/Web/API/Screen/left +/ja/docs/DOM:window.screen.left /ja/docs/Web/API/ScreenDetailed/left /ja/docs/DOM:window.screen.pixelDepth /ja/docs/Web/API/Screen/pixelDepth -/ja/docs/DOM:window.screen.top /ja/docs/Web/API/Screen/top +/ja/docs/DOM:window.screen.top /ja/docs/Web/API/ScreenDetailed/top /ja/docs/DOM:window.screen.width /ja/docs/Web/API/Screen/width /ja/docs/DOM:window.screenX /ja/docs/Web/API/Window/screenX /ja/docs/DOM:window.screenY /ja/docs/Web/API/Window/screenY @@ -3048,7 +3048,11 @@ /ja/docs/Web/API/Resource_Timing_API/Using_the_Resource_Timing_API /ja/docs/Web/API/Performance_API/Resource_timing /ja/docs/Web/API/Response/error /ja/docs/Web/API/Response/error_static /ja/docs/Web/API/Response/redirect /ja/docs/Web/API/Response/redirect_static +/ja/docs/Web/API/Screen/availLeft /ja/docs/Web/API/ScreenDetailed/availLeft +/ja/docs/Web/API/Screen/availTop /ja/docs/Web/API/ScreenDetailed/availTop +/ja/docs/Web/API/Screen/left /ja/docs/Web/API/ScreenDetailed/left /ja/docs/Web/API/Screen/onorientationchange /ja/docs/Web/API/Screen/orientationchange_event +/ja/docs/Web/API/Screen/top /ja/docs/Web/API/ScreenDetailed/top /ja/docs/Web/API/ScrollToOptions /ja/docs/Web/API/Window/scroll /ja/docs/Web/API/ServiceWorkerContainer/oncontrollerchange /ja/docs/Web/API/ServiceWorkerContainer/controllerchange_event /ja/docs/Web/API/ServiceWorkerContainer/onerror /ja/docs/Web/API/ServiceWorkerContainer/error_event @@ -3415,14 +3419,14 @@ /ja/docs/Web/API/window.resizeTo /ja/docs/Web/API/Window/resizeTo /ja/docs/Web/API/window.screen /ja/docs/Web/API/Window/screen /ja/docs/Web/API/window.screen.availHeight /ja/docs/Web/API/Screen/availHeight -/ja/docs/Web/API/window.screen.availLeft /ja/docs/Web/API/Screen/availLeft -/ja/docs/Web/API/window.screen.availTop /ja/docs/Web/API/Screen/availTop +/ja/docs/Web/API/window.screen.availLeft /ja/docs/Web/API/ScreenDetailed/availLeft +/ja/docs/Web/API/window.screen.availTop /ja/docs/Web/API/ScreenDetailed/availTop /ja/docs/Web/API/window.screen.availWidth /ja/docs/Web/API/Screen/availWidth /ja/docs/Web/API/window.screen.colorDepth /ja/docs/Web/API/Screen/colorDepth /ja/docs/Web/API/window.screen.height /ja/docs/Web/API/Screen/height -/ja/docs/Web/API/window.screen.left /ja/docs/Web/API/Screen/left +/ja/docs/Web/API/window.screen.left /ja/docs/Web/API/ScreenDetailed/left /ja/docs/Web/API/window.screen.pixelDepth /ja/docs/Web/API/Screen/pixelDepth -/ja/docs/Web/API/window.screen.top /ja/docs/Web/API/Screen/top +/ja/docs/Web/API/window.screen.top /ja/docs/Web/API/ScreenDetailed/top /ja/docs/Web/API/window.screen.width /ja/docs/Web/API/Screen/width /ja/docs/Web/API/window.screenX /ja/docs/Web/API/Window/screenX /ja/docs/Web/API/window.screenY /ja/docs/Web/API/Window/screenY diff --git a/files/ja/_wikihistory.json b/files/ja/_wikihistory.json index 9946100bc9c154..592bb730878670 100644 --- a/files/ja/_wikihistory.json +++ b/files/ja/_wikihistory.json @@ -12134,27 +12134,6 @@ "modified": "2020-10-15T21:16:25.668Z", "contributors": ["mfuji09", "fscholz", "soumya", "ethertank", "Potappo"] }, - "Web/API/Screen/availLeft": { - "modified": "2020-10-15T21:16:27.232Z", - "contributors": [ - "mfuji09", - "wbamberg", - "fscholz", - "khalid32", - "ethertank", - "Potappo" - ] - }, - "Web/API/Screen/availTop": { - "modified": "2020-10-15T21:16:28.901Z", - "contributors": [ - "mfuji09", - "fscholz", - "basemnassar11", - "ethertank", - "Potappo" - ] - }, "Web/API/Screen/availWidth": { "modified": "2019-03-23T23:50:19.480Z", "contributors": ["fscholz", "jsx", "ethertank", "Potappo"] @@ -12167,10 +12146,6 @@ "modified": "2020-10-15T21:16:36.031Z", "contributors": ["mfuji09", "fscholz", "khalid32", "ethertank", "Potappo"] }, - "Web/API/Screen/left": { - "modified": "2020-10-15T21:16:25.501Z", - "contributors": ["mfuji09", "fscholz", "jsx", "ethertank", "Potappo"] - }, "Web/API/Screen/lockOrientation": { "modified": "2020-10-15T21:52:16.220Z", "contributors": ["mfuji09", "shuuji3"] @@ -12201,23 +12176,48 @@ "Potappo" ] }, - "Web/API/Screen/top": { - "modified": "2020-10-15T21:16:26.905Z", + "Web/API/Screen/unlockOrientation": { + "modified": "2020-10-15T21:52:16.003Z", + "contributors": ["mfuji09", "shuuji3"] + }, + "Web/API/Screen/width": { + "modified": "2020-10-15T21:16:26.560Z", + "contributors": ["mfuji09", "fscholz", "khalid32", "ethertank", "Potappo"] + }, + "Web/API/ScreenDetailed/availLeft": { + "modified": "2020-10-15T21:16:27.232Z", "contributors": [ "mfuji09", + "wbamberg", "fscholz", - "AshfaqHossain", + "khalid32", "ethertank", "Potappo" ] }, - "Web/API/Screen/unlockOrientation": { - "modified": "2020-10-15T21:52:16.003Z", - "contributors": ["mfuji09", "shuuji3"] + "Web/API/ScreenDetailed/availTop": { + "modified": "2020-10-15T21:16:28.901Z", + "contributors": [ + "mfuji09", + "fscholz", + "basemnassar11", + "ethertank", + "Potappo" + ] }, - "Web/API/Screen/width": { - "modified": "2020-10-15T21:16:26.560Z", - "contributors": ["mfuji09", "fscholz", "khalid32", "ethertank", "Potappo"] + "Web/API/ScreenDetailed/left": { + "modified": "2020-10-15T21:16:25.501Z", + "contributors": ["mfuji09", "fscholz", "jsx", "ethertank", "Potappo"] + }, + "Web/API/ScreenDetailed/top": { + "modified": "2020-10-15T21:16:26.905Z", + "contributors": [ + "mfuji09", + "fscholz", + "AshfaqHossain", + "ethertank", + "Potappo" + ] }, "Web/API/ScriptProcessorNode": { "modified": "2019-03-23T22:35:37.748Z", diff --git a/files/ja/web/api/screen/availleft/index.md b/files/ja/web/api/screendetailed/availleft/index.md similarity index 94% rename from files/ja/web/api/screen/availleft/index.md rename to files/ja/web/api/screendetailed/availleft/index.md index 7c9365c8626f59..975ffc0f3304bd 100644 --- a/files/ja/web/api/screen/availleft/index.md +++ b/files/ja/web/api/screendetailed/availleft/index.md @@ -1,6 +1,7 @@ --- title: Screen.availLeft -slug: Web/API/Screen/availLeft +slug: Web/API/ScreenDetailed/availLeft +original_slug: Web/API/Screen/availLeft --- {{APIRef("CSSOM")}}{{Non-standard_Header}} diff --git a/files/ja/web/api/screen/availtop/index.md b/files/ja/web/api/screendetailed/availtop/index.md similarity index 87% rename from files/ja/web/api/screen/availtop/index.md rename to files/ja/web/api/screendetailed/availtop/index.md index 22a61099b9312e..6db3b43cbf88f0 100644 --- a/files/ja/web/api/screen/availtop/index.md +++ b/files/ja/web/api/screendetailed/availtop/index.md @@ -1,6 +1,7 @@ --- title: Screen.availTop -slug: Web/API/Screen/availTop +slug: Web/API/ScreenDetailed/availTop +original_slug: Web/API/Screen/availTop --- {{APIRef("CSSOM")}}{{Non-standard_Header}} diff --git a/files/ja/web/api/screen/left/index.md b/files/ja/web/api/screendetailed/left/index.md similarity index 81% rename from files/ja/web/api/screen/left/index.md rename to files/ja/web/api/screendetailed/left/index.md index 40f92dbe3e7622..ccb5e030683d3d 100644 --- a/files/ja/web/api/screen/left/index.md +++ b/files/ja/web/api/screendetailed/left/index.md @@ -1,6 +1,7 @@ --- title: Screen.left -slug: Web/API/Screen/left +slug: Web/API/ScreenDetailed/left +original_slug: Web/API/Screen/left --- {{APIRef("CSSOM")}}{{Non-standard_Header}} diff --git a/files/ja/web/api/screen/top/index.md b/files/ja/web/api/screendetailed/top/index.md similarity index 83% rename from files/ja/web/api/screen/top/index.md rename to files/ja/web/api/screendetailed/top/index.md index 788f03c62fabb6..ae65fc42b2519b 100644 --- a/files/ja/web/api/screen/top/index.md +++ b/files/ja/web/api/screendetailed/top/index.md @@ -1,6 +1,7 @@ --- title: Screen.top -slug: Web/API/Screen/top +slug: Web/API/ScreenDetailed/top +original_slug: Web/API/Screen/top --- {{APIRef("CSSOM")}}{{deprecated_header}}{{Non-standard_Header}} diff --git a/files/ja/web/javascript/reference/global_objects/typedarray/index.md b/files/ja/web/javascript/reference/global_objects/typedarray/index.md index 08e97ae128077e..a445441dad3233 100644 --- a/files/ja/web/javascript/reference/global_objects/typedarray/index.md +++ b/files/ja/web/javascript/reference/global_objects/typedarray/index.md @@ -19,19 +19,19 @@ l10n: ### TypedArray オブジェクト -| 型 | 値の範囲 | サイズ (バイト数) | 説明 | Web IDL 型 | 同等の C 型 | -| ------------------------------- | ---------------------------------------------------------- | ----------------- | ------------------------------------------------------------------------------------------------------ | --------------------- | -------------------------------------------------------------------- | -| {{jsxref("Int8Array")}} | -128 から 127 | 1 | 8 ビット長、2 の補数方式の符号付き整数値 | `byte` | `int8_t` | -| {{jsxref("Uint8Array")}} | 0 から 255 | 1 | 8 ビット長、符号なし整数値 | `octet` | `uint8_t` | -| {{jsxref("Uint8ClampedArray")}} | 0 から 255 | 1 | 8 ビット長、符号なし整数値 (切り詰め) | `octet` | `uint8_t` | -| {{jsxref("Int16Array")}} | -32768 から 32767 | 2 | 16 ビット長、2 の補数方式の符号付き整数値 | `short` | `int16_t` | -| {{jsxref("Uint16Array")}} | 0 から 65535 | 2 | 16 ビット長、符号なし整数値 | `unsigned short` | `uint16_t` | -| {{jsxref("Int32Array")}} | -2147483648 から 2147483647 | 4 | 32 ビット長、2 の補数方式の符号付き整数値 | `long` | `int32_t` | -| {{jsxref("Uint32Array")}} | 0 から 4294967295 | 4 | 32 ビット長、符号なし整数値 | `unsigned long` | `uint32_t` | -| {{jsxref("Float32Array")}} | `-3.4E38` から `3.4E38` および `1.2E-38` (最小の正の数) | 4 | 32 ビット長 IEEE 方式浮動小数点数 (有効桁数 7 桁、例えば `1.234567`) | `unrestricted float` | `float` | -| {{jsxref("Float64Array")}} | `-1.8E308` から `1.8E308` および `5E-324` (最小の正の数) | 8 | 64 ビット長 IEEE 方式浮動小数点数 (有効桁数 16 桁、例えば`1.23456789012345`) | `unrestricted double` | `double` | -| {{jsxref("BigInt64Array")}} | -263 to 263 - 1 | 8 | 64 ビット長、2 の補数方式の符号付き整数値 | `bigint` | `int64_t (signed long long)` | -| {{jsxref("BigUint64Array")}} | 0 to 264 - 1 | 8 | 64 ビット長、符号なし整数値 | `bigint` | `uint64_t (unsigned long long)` | +| 型 | 値の範囲 | サイズ (バイト数) | 説明 | Web IDL 型 | 同等の C 型 | +| ------------------------------- | ---------------------------------------------------------- | ----------------- | ---------------------------------------------------------------------------- | --------------------- | ------------------------------- | +| {{jsxref("Int8Array")}} | -128 から 127 | 1 | 8 ビット長、2 の補数方式の符号付き整数値 | `byte` | `int8_t` | +| {{jsxref("Uint8Array")}} | 0 から 255 | 1 | 8 ビット長、符号なし整数値 | `octet` | `uint8_t` | +| {{jsxref("Uint8ClampedArray")}} | 0 から 255 | 1 | 8 ビット長、符号なし整数値 (切り詰め) | `octet` | `uint8_t` | +| {{jsxref("Int16Array")}} | -32768 から 32767 | 2 | 16 ビット長、2 の補数方式の符号付き整数値 | `short` | `int16_t` | +| {{jsxref("Uint16Array")}} | 0 から 65535 | 2 | 16 ビット長、符号なし整数値 | `unsigned short` | `uint16_t` | +| {{jsxref("Int32Array")}} | -2147483648 から 2147483647 | 4 | 32 ビット長、2 の補数方式の符号付き整数値 | `long` | `int32_t` | +| {{jsxref("Uint32Array")}} | 0 から 4294967295 | 4 | 32 ビット長、符号なし整数値 | `unsigned long` | `uint32_t` | +| {{jsxref("Float32Array")}} | `-3.4E38` から `3.4E38` および `1.2E-38` (最小の正の数) | 4 | 32 ビット長 IEEE 方式浮動小数点数 (有効桁数 7 桁、例えば `1.234567`) | `unrestricted float` | `float` | +| {{jsxref("Float64Array")}} | `-1.8E308` から `1.8E308` および `5E-324` (最小の正の数) | 8 | 64 ビット長 IEEE 方式浮動小数点数 (有効桁数 16 桁、例えば`1.23456789012345`) | `unrestricted double` | `double` | +| {{jsxref("BigInt64Array")}} | -263 to 263 - 1 | 8 | 64 ビット長、2 の補数方式の符号付き整数値 | `bigint` | `int64_t (signed long long)` | +| {{jsxref("BigUint64Array")}} | 0 to 264 - 1 | 8 | 64 ビット長、符号なし整数値 | `bigint` | `uint64_t (unsigned long long)` | ### サイズ変更可能なバッファー表示時の動作について diff --git a/files/zh-cn/_redirects.txt b/files/zh-cn/_redirects.txt index 39eb06181418f1..b4812509ea1aa6 100644 --- a/files/zh-cn/_redirects.txt +++ b/files/zh-cn/_redirects.txt @@ -1730,13 +1730,15 @@ /zh-CN/docs/Web/API/SVGMatrix /zh-CN/docs/Web/API/DOMMatrix /zh-CN/docs/Web/API/SVGPathElement/getTotalLength /zh-CN/docs/Web/API/SVGGeometryElement/getTotalLength /zh-CN/docs/Web/API/Screen.availHeight /zh-CN/docs/Web/API/Screen/availHeight -/zh-CN/docs/Web/API/Screen.availLeft /zh-CN/docs/Web/API/Screen/availLeft -/zh-CN/docs/Web/API/Screen.availTop /zh-CN/docs/Web/API/Screen/availTop +/zh-CN/docs/Web/API/Screen.availLeft /zh-CN/docs/Web/API/ScreenDetailed/availLeft +/zh-CN/docs/Web/API/Screen.availTop /zh-CN/docs/Web/API/ScreenDetailed/availTop /zh-CN/docs/Web/API/Screen.availWidth /zh-CN/docs/Web/API/Screen/availWidth /zh-CN/docs/Web/API/Screen.colorDepth /zh-CN/docs/Web/API/Screen/colorDepth /zh-CN/docs/Web/API/Screen.height /zh-CN/docs/Web/API/Screen/height /zh-CN/docs/Web/API/Screen.pixelDepth /zh-CN/docs/Web/API/Screen/pixelDepth /zh-CN/docs/Web/API/Screen.width /zh-CN/docs/Web/API/Screen/width +/zh-CN/docs/Web/API/Screen/availLeft /zh-CN/docs/Web/API/ScreenDetailed/availLeft +/zh-CN/docs/Web/API/Screen/availTop /zh-CN/docs/Web/API/ScreenDetailed/availTop /zh-CN/docs/Web/API/ScrollToOptions /zh-CN/docs/Web/API/Window/scroll /zh-CN/docs/Web/API/Selection.addRange /zh-CN/docs/Web/API/Selection/addRange /zh-CN/docs/Web/API/Selection.anchorNode /zh-CN/docs/Web/API/Selection/anchorNode diff --git a/files/zh-cn/_wikihistory.json b/files/zh-cn/_wikihistory.json index f3d3568c18b471..39490efaae8cdf 100644 --- a/files/zh-cn/_wikihistory.json +++ b/files/zh-cn/_wikihistory.json @@ -13176,14 +13176,6 @@ "modified": "2019-03-23T23:10:33.122Z", "contributors": ["teoli", "AlexChao"] }, - "Web/API/Screen/availLeft": { - "modified": "2019-03-23T23:10:32.405Z", - "contributors": ["teoli", "khalid32", "AlexChao"] - }, - "Web/API/Screen/availTop": { - "modified": "2019-03-23T23:10:26.366Z", - "contributors": ["teoli", "khalid32", "AlexChao"] - }, "Web/API/Screen/availWidth": { "modified": "2019-03-23T23:10:30.530Z", "contributors": ["teoli", "AlexChao"] @@ -13212,6 +13204,14 @@ "modified": "2019-03-23T23:10:29.689Z", "contributors": ["teoli", "AlexChao"] }, + "Web/API/ScreenDetailed/availLeft": { + "modified": "2019-03-23T23:10:32.405Z", + "contributors": ["teoli", "khalid32", "AlexChao"] + }, + "Web/API/ScreenDetailed/availTop": { + "modified": "2019-03-23T23:10:26.366Z", + "contributors": ["teoli", "khalid32", "AlexChao"] + }, "Web/API/Screen_Capture_API": { "modified": "2020-10-15T22:30:44.340Z", "contributors": ["hzy", "Sheppy"] diff --git a/files/zh-cn/web/api/screen/availleft/index.md b/files/zh-cn/web/api/screendetailed/availleft/index.md similarity index 93% rename from files/zh-cn/web/api/screen/availleft/index.md rename to files/zh-cn/web/api/screendetailed/availleft/index.md index 834f9266479dd3..c541a75bffc7ae 100644 --- a/files/zh-cn/web/api/screen/availleft/index.md +++ b/files/zh-cn/web/api/screendetailed/availleft/index.md @@ -1,6 +1,7 @@ --- title: Screen.availLeft -slug: Web/API/Screen/availLeft +slug: Web/API/ScreenDetailed/availLeft +original_slug: Web/API/Screen/availLeft --- {{ ApiRef() }} diff --git a/files/zh-cn/web/api/screen/availtop/index.md b/files/zh-cn/web/api/screendetailed/availtop/index.md similarity index 86% rename from files/zh-cn/web/api/screen/availtop/index.md rename to files/zh-cn/web/api/screendetailed/availtop/index.md index 9d5dae56918393..b192547f5f0921 100644 --- a/files/zh-cn/web/api/screen/availtop/index.md +++ b/files/zh-cn/web/api/screendetailed/availtop/index.md @@ -1,6 +1,7 @@ --- title: Screen.availTop -slug: Web/API/Screen/availTop +slug: Web/API/ScreenDetailed/availTop +original_slug: Web/API/Screen/availTop --- {{ ApiRef() }} diff --git a/files/zh-cn/web/javascript/reference/global_objects/weakset/index.md b/files/zh-cn/web/javascript/reference/global_objects/weakset/index.md index 1fef5b69176874..0ddcaf14b94573 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/weakset/index.md +++ b/files/zh-cn/web/javascript/reference/global_objects/weakset/index.md @@ -5,18 +5,18 @@ slug: Web/JavaScript/Reference/Global_Objects/WeakSet {{JSRef}} -**`WeakSet`** 对象允许你将弱保持*对象*存储在一个集合中。 +**`WeakSet`** 是可被垃圾回收的值的集合,包括对象和[非全局注册的符号](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Symbol#全局共享的_symbol)。`WeakSet` 中的值只能出现一次。它在 `WeakSet` 的集合中是唯一的。 ## 描述 -`WeakSet` 对象是一些对象值的集合。且其与 {{jsxref("Set")}} 类似,`WeakSet` 中的每个对象值都只能出现一次。在 `WeakSet` 的集合中,所有对象都是唯一的。 +WeakSet 中的值一定是可被垃圾回收的值。大多数{{Glossary("Primitive", "原始数据类型")}}可以被任意地创建,并且没有生命周期,所以它们不能被存储。对象和[非全局注册的符号](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Symbol#全局共享的_symbol)可以被存储,因为它们是可被垃圾回收的值。 它和 {{jsxref("Set")}} 对象的主要区别有: -- `WeakSet` **只能是对象**的集合,而不能像 {{jsxref("Set")}} 那样,可以是任何类型的任意值。 -- `WeakSet` 持*弱引用*:集合中对象的引用为*弱*引用。如果没有其他的对 `WeakSet` 中对象的引用,那么这些对象会被当成垃圾回收掉。 +- `WeakSet` **只能是对象和符号**的集合,它不能像 {{jsxref("Set")}} 那样包含任何类型的任意值。 +- `WeakSet` 持*弱引用*:`WeakSet` 中对象的引用为*弱*引用。如果没有其他的对 `WeakSet` 中对象的引用存在,那么这些对象会被垃圾回收。 -> **备注:** 这也意味着 `WeakSet` 中没有存储当前对象的列表。正因为这样,`WeakSet` 是不可枚举的。 + > **备注:** 这也意味着集合中没有存储当前值的列表。`WeakSet` 是不可枚举的。 ### 用例:检测循环引用 @@ -25,7 +25,7 @@ slug: Web/JavaScript/Reference/Global_Objects/WeakSet 为此,`WeakSet` 非常适合处理这种情况: ```js -// 对 传入的 subject 对象 内部存储的所有内容执行回调 +// 对传入的 subject 对象内部存储的所有内容执行回调 function execRecursively(fn, subject, _refs = new WeakSet()) { // 避免无限递归 if (_refs.has(subject)) { @@ -61,14 +61,23 @@ execRecursively((obj) => console.log(obj), foo); - {{jsxref("WeakSet/WeakSet", "WeakSet()")}} - : 创建一个新的 `WeakSet` 对象。 +## 实例属性 + +这些属性在 `WeakSet.prototype` 上定义,并且由所有 `WeakSet` 实例所共享。 + +- {{jsxref("Object/constructor", "WeakSet.prototype.constructor")}} + - : 创建了该实例对象的构造函数。对于 `WeakSet` 实例,初始值是 {{jsxref("WeakSet/WeakSet", "WeakSet")}} 构造函数。 +- `WeakSet.prototype[@@toStringTag]` + - : [`@@toStringTag`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toStringTag) 属性的初始值是字符串 `"WeakSet"`。该属性被 {{jsxref("Object.prototype.toString()")}} 所使用。 + ## 实例方法 -- {{jsxref("WeakSet.add", "WeakSet.prototype.add(value)")}} - - : 将 `value` 添加到 `WeakSet` 对象最后一个元素的后面。 -- {{jsxref("WeakSet.delete", "WeakSet.prototype.delete(value)")}} +- {{jsxref("WeakSet.prototype.add()")}} + - : 将 `value` 追加到 `WeakSet` 对象。 +- {{jsxref("WeakSet.prototype.delete()")}} - : 从 `WeakSet` 中移除 `value`。此后调用 `WeakSet.prototype.has(value)` 将返回 `false`。 -- {{jsxref("WeakSet.has", "WeakSet.prototype.has(value)")}} - - : 返回一个布尔值,表示 `value` 是否存在于 `WeakSet` 对象中。 +- {{jsxref("WeakSet.prototype.has()")}} + - : 返回一个表示 `value` 是否存在于 `WeakSet` 对象中的布尔值。 ## 示例 @@ -90,7 +99,7 @@ ws.has(foo); // false,foo 对象已经被删除了 ws.has(bar); // true,bar 依然存在 ``` -注意,`foo !== bar`。尽管它们是相似的对象,但是它们不是**_同一个对象_**。因此,它们都可以被加入到 set 中。 +注意,`foo !== bar`。尽管它们是相似的对象,_但是它们不是**同一个对象**_。因此,它们都可以被加入到集合中。 ## 规范