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: sync the translayion of "Equality comparisons and sameness" #24195

Merged
merged 4 commits into from
Oct 29, 2024

Conversation

familyboat
Copy link
Contributor

Description

英文版有了更新,对中文版进行同步。

Motivation

Additional details

Related issues and pull requests

@familyboat familyboat requested a review from a team as a code owner October 22, 2024 10:32
@familyboat familyboat requested review from t7yang and removed request for a team October 22, 2024 10:32
@github-actions github-actions bot added the l10n-zh Issues related to Chinese content. label Oct 22, 2024
Copy link
Contributor

github-actions bot commented Oct 22, 2024

Preview URLs

Flaws (1)

URL: /zh-CN/docs/Web/JavaScript/Equality_comparisons_and_sameness
Title: 相等比较和相同
Flaw count: 1

  • broken_links:
    • Can't resolve /zh-CN/docs/Web/JavaScript/Typed_arrays
External URLs (1)

URL: /zh-CN/docs/Web/JavaScript/Equality_comparisons_and_sameness
Title: 相等比较和相同

(comment last updated: 2024-10-29 06:01:03)

@@ -47,7 +49,7 @@ console.log(obj === null); // false
console.log(obj === undefined); // false
```

在日常中使用严格相等几乎总是正确的选择。对于除了数值之外的值,严格相等使用明确的语义进行比较:一个值只与自身严格相等。对于数值,严格相等使用略加修改的语义来处理两个特殊情况:第一个情况是,浮点数 0 是不分正负的。区分 `+0` 和 `-0` 在解决一些特定的数学问题时是必要的,但是大部分情况下我们并不用关心。严格相等认为这两个值是全等的。第二个情况是,浮点数包含了 `NaN` 值,用来表示某些定义不明确的数学问题的解,例如:正无穷加负无穷。严格相等认为 `NaN` 与其他任何值都不全等,包括它自己。(等式 `(x !== x)` 成立的唯一情况是 `x` 的值为 `NaN`)
使用严格相等几乎总是正确的选择。对于除了数字之外的值,严格相等有着明确的语义:值仅与它自身相等。对于数字,严格相等有着稍微不同的语义处理两个特殊情况:第一个情况是,浮点数 0 是不分正负的。区分 `+0` 和 `-0` 在解决一些特定的数学问题时区分正负是必要的,但是大部分情况下我们并不用关心。严格相等认为这两个值是全等的。第二个情况是,浮点数包含了 `NaN` 值,用来表示某些定义不明确的数学问题的解,例如:正无穷加负无穷。严格相等认为 `NaN` 与其他任何值都不全等,包括它自己。(等式 `(x !== x)` 成立的唯一情况是 `x` 的值为 `NaN`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对于数字,严格相等有着稍微不同的语义处理两个特殊情况

对于这句话,我感觉用“使用”更好,“有着”后面一般直接跟宾语(不会额外附加内容了)

@@ -141,13 +143,13 @@ function sameValueZero(x, y) {
}
```

零值相等与严格相等的区别在于其将 `NaN` 视作是相等的,与同值相等的区别在于其将 `-0` 和 `0` 视作相等的。这使得它在搜索期间通常具有最实用的行为,特别是在与 `NaN` 一起使用时。它被用于 [`Array.prototype.includes()`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)、[`TypedArray.prototype.includes()`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes) 及 [`Map`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Map) 和 [`Set`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Set) 方法用来比较键的相等性
零值相等与严格相等的区别在于其将 `NaN` 视作是相等的,与同值相等的区别在于其将 `-0` 和 `0` 视作相等的。这使得它在搜索期间通常具有最实用的行为,特别是在处理 `NaN` 。它被用于 [`Array.prototype.includes()`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)、[`TypedArray.prototype.includes()`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes) 及 [`Map`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Map) 和 [`Set`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Set) 需要比较键的相等性的方法中
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
零值相等与严格相等的区别在于其将 `NaN` 视作是相等的,与同值相等的区别在于其将 `-0``0` 视作相等的。这使得它在搜索期间通常具有最实用的行为,特别是在处理 `NaN` 时。它被用于 [`Array.prototype.includes()`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)[`TypedArray.prototype.includes()`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes)[`Map`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Map)[`Set`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Set) 需要比较键的相等性的方法中
零值相等与严格相等的区别在于其将 `NaN` 视作是相等的,与同值相等的区别在于其将 `-0``0` 视作相等的。这使得它在搜索期间通常具有最实用的行为,特别是在处理 `NaN` 时。它被用于 [`Array.prototype.includes()`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/includes)[`TypedArray.prototype.includes()`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/includes),以及及 [`Map`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Map)[`Set`](/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Set) 的需要比较键的相等性的方法

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

“以及及”是不是多了一个“及”

@@ -1,6 +1,8 @@
---
title: JavaScript 中的相等性判断
title: 相等比较和相同
Copy link
Member

@yin1999 yin1999 Oct 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

相等性比较和相同性?(不确定是否会更好一点)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我想到一个数学上的定义,自反性。我理解“性”代表的是抽象。而这里我认为是在指代两个具体的是否相等,是否相同。

@familyboat
Copy link
Contributor Author

已应用评论意见。有异议的地方做了相应的评论。

@familyboat familyboat requested a review from yin1999 October 29, 2024 06:00
Copy link
Member

@yin1999 yin1999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@yin1999 yin1999 changed the title zh-cn: sync the translayion of "Equality_comparisons_and_sameness" zh-cn: sync the translayion of "Equality comparisons and sameness" Oct 29, 2024
@yin1999 yin1999 merged commit 48a473e into mdn:main Oct 29, 2024
7 checks passed
@familyboat familyboat deleted the update_Equality_comparisons_and_sameness branch October 29, 2024 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
l10n-zh Issues related to Chinese content.
Projects
Development

Successfully merging this pull request may close these issues.

2 participants