Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zh-cn]: update the translation of Set.add()&clear()&delete()&has() #16479

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ slug: Web/JavaScript/Reference/Global_Objects/Set/add

{{JSRef}}

如果 `Set` 对象中没有具有相同值的元素,则 **`add()`** 方法将插入一个具有指定值的新元素到 `Set` 对象中
{{jsxref("Set")}} 实例的 **`add()`** 方法会在该集合中插入一个具有指定值的新元素,如果该 `Set` 对象中没有具有相同值的元素

{{EmbedInteractiveExample("pages/js/set-prototype-add.html")}}

Expand All @@ -22,7 +22,7 @@ add(value)

### 返回值

`Set` 对象本身
添加了值的 `Set` 对象

## 示例

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ slug: Web/JavaScript/Reference/Global_Objects/Set/clear

{{JSRef}}

**`clear()`** 方法移除 `Set` 对象中所有元素
{{jsxref("Set")}} 实例的 **`clear()`** 方法移除该集合中的所有元素

{{EmbedInteractiveExample("pages/js/set-prototype-clear.html")}}

Expand All @@ -15,12 +15,18 @@ slug: Web/JavaScript/Reference/Global_Objects/Set/clear
clear()
```

### 参数

无。

### 返回值

{{jsxref("undefined")}}。
无({{jsxref("undefined")}}

## 示例

### 使用 clear() 方法

```js
const mySet = new Set();
mySet.add(1);
Expand All @@ -32,7 +38,7 @@ console.log(mySet.has("foo")); // true
mySet.clear();

console.log(mySet.size); // 0
console.log(mySet.has("foo")); // false
console.log(mySet.has("bar")); // false
JasonLamv-t marked this conversation as resolved.
Show resolved Hide resolved
JasonLamv-t marked this conversation as resolved.
Show resolved Hide resolved
```

## 规范
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ slug: Web/JavaScript/Reference/Global_Objects/Set/delete

{{JSRef}}

**`delete()`** 方法从 `Set` 对象中删除指定的值(如果该值在 `Set` 中)
{{jsxref("Set")}} 实例的 **`delete()`** 方法从该集合中删除指定值,如果该值在集合中

{{EmbedInteractiveExample("pages/js/set-prototype-delete.html")}}

## 语法

```js-nolint
delete(value)
setInstance.delete(value)
```

### 参数
Expand Down Expand Up @@ -40,7 +40,7 @@ console.log(mySet.has("foo")); // 返回 false,"foo" 已经成功删除

### 从 Set 中删除对象

因为对象是通过引用比较的,所以如果没有对原始对象的引用,就必须通过检查单个属性来删除它们
因为对象是通过引用比较的,所以如果没有对原始对象的引用,就必须通过检查各个属性来删除它们

```js
const setObj = new Set(); // 创建一个新 set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ slug: Web/JavaScript/Reference/Global_Objects/Set/has

{{JSRef}}

**`has()`** 方法返回一个布尔值来指示对应的值是否存在于 `Set` 对象中
{{jsxref("Set")}} 实例的 **`has()`** 方法返回一个布尔值来指示对应的值是否存在于该集合中

{{EmbedInteractiveExample("pages/js/set-prototype-has.html")}}

Expand Down