Skip to content

Commit efdc05c

Browse files
yyxygitbemself
andcommitted
tiny translation update (#587)
* object#copying-by-reference - Comparison by reference:tiny translation issue * tiny update & 05-array-methods: add task 12-reduce-object * Update 1-js/05-data-types/05-array-methods/article.md - [arr.copyWithin(target, start, end)](mdn:js/Array/copyWithin) — 将从 `start`(开始)位置到 `end`(结束)位置 [译注:不包含结束位元素] 的所有元素复制到 *自身* 的 `target`(目标)位置中(覆盖现有元素)。 这样怎么样? Co-Authored-By: bemself <45781328+bemself@users.noreply.github.com> * modify from 'changes requested' * remove extra spaces Co-authored-by: bemself <45781328+bemself@users.noreply.github.com>
1 parent 8053ab3 commit efdc05c

File tree

5 files changed

+16
-15
lines changed

5 files changed

+16
-15
lines changed

1-js/05-data-types/03-string/article.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,16 +525,16 @@ alert( str );
525525
526526
字符通过数字代码进行比较。越大的代码意味着字符越大。`a`(97)的代码大于 `Z`(90)。
527527
528-
- 所有小写字母都是大写字母,因为它们的代码更大。
529-
- 一些想 `Ö` 的字母与主要字母表不同。这里的代码比从 `a``z` 的代码都要大。
528+
- 所有小写字母追随在大写字母之后,因为它们的代码更大。
529+
- 一些像 `Ö` 的字母与主要字母表不同。这里,它的代码比任何从 `a``z` 的代码都要大。
530530
531531
### 正确的比较
532532
533533
执行字符串比较的“正确”算法比看起来更复杂,因为不同语言的字母都不相同。
534534
535535
因此浏览器需要知道要比较的语言。
536536
537-
幸运地是,所有现代浏览器(IE-10 都需要额外的库 [Intl.JS](https://github.com/andyearnshaw/Intl.js/)) 支持国际化标准 [ECMA 402](http://www.ecma-international.org/ecma-402/1.0/ECMA-402.pdf)。
537+
幸运地是,所有现代浏览器(IE10- 需要额外的库 [Intl.JS](https://github.com/andyearnshaw/Intl.js/)) 支持国际化标准 [ECMA 402](http://www.ecma-international.org/ecma-402/1.0/ECMA-402.pdf)。
538538
539539
它提供了一种特殊的方法来比较不同语言的字符串,遵循它们的规则。
540540

1-js/05-data-types/05-array-methods/1-camelcase/task.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ importance: 5
66

77
写函数 `camelize(str)` 将诸如 "my-short-string" 之类的由短划线分隔的单词变成骆驼式的 "myShortString"。
88

9-
即:删除所有短横线,短横线后的第一个单词变为大写
9+
即:删除所有短横线,短横线后的每一个单词变为首字母大写
1010

1111
例如:
1212

1-js/05-data-types/05-array-methods/12-reduce-object/task.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ importance: 4
22

33
---
44

5-
# Create keyed object from array
5+
# 从数组创建键(值)对象
66

7-
Let's say we received an array of users in the form `{id:..., name:..., age... }`.
7+
假设我们有以下形式的用户数组 `{id:..., name:..., age... }`
88

9-
Create a function `groupById(arr)` that creates an object from it, with `id` as the key, and array items as values.
9+
创建一个函数 `groupById(arr)` 从该数组创建对象,以 `id` 为键(key),数组项为值。
1010

11-
For example:
11+
例如:
1212

1313
```js
1414
let users = [
@@ -20,7 +20,7 @@ let users = [
2020
let usersById = groupById(users);
2121

2222
/*
23-
// after the call we have:
23+
// 调用方法后我们得到:
2424
2525
usersById = {
2626
john: {id: 'john', name: "John Smith", age: 20}
@@ -30,8 +30,9 @@ usersById = {
3030
*/
3131
```
3232

33-
Such function is really handy when working with server data.
3433

35-
In this task we assume that `id` is unique. There may be no two array items with the same `id`.
34+
处理服务端数据时,此功能很有用。
3635

37-
Please use array `.reduce` method in the solution.
36+
在这个任务里我们假设 `id` 是唯一的。没有哪两个数组项具有相同的 `id`
37+
38+
请使用数组 `.reduce` 方法解决。

1-js/05-data-types/05-array-methods/9-shuffle/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ JavaScript 引擎的代码结果可能会有所不同,但我们已经可以看
6767
```js
6868
function shuffle(array) {
6969
for (let i = array.length - 1; i > 0; i--) {
70-
let j = Math.floor(Math.random() * (i + 1)); // r 从 0 到 i 的随机索引
70+
let j = Math.floor(Math.random() * (i + 1)); // 从 0 到 i 的随机索引
7171
[array[i], array[j]] = [array[j], array[i]]; // 交换元素
7272
}
7373
}

1-js/05-data-types/05-array-methods/article.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ alert(youngerUsers.length); // 2
692692
- 查询元素:
693693
- `indexOf/lastIndexOf(item, pos)` — 从 `pos` 找到 `item`,则返回索引否则返回 `-1`
694694
- `includes(value)` — 如果数组有 `value`,则返回 `true`,否则返回 `false`
695-
- `find/filter(func)` — 通过函数过滤元素,返回 `true` 条件的符合 find 函数的第一个值或符合 filter 函数的全部值
695+
- `find/filter(func)` — 通过函数过滤元素,返回符合 `true` 条件的第一个值/所有值
696696
- `findIndex``find` 类似,但返回索引而不是值。
697697

698698
- 转换数组:
@@ -718,7 +718,7 @@ alert(youngerUsers.length); // 2
718718

719719
- [arr.fill(value, start, end)](mdn:js/Array/fill) — 从 `start``end``value` 重复填充数组。
720720

721-
- [arr.copyWithin(target, start, end)](mdn:js/Array/copyWithin)copies its elements from position `start` till position `end` into *itself*, at position `target` (overwrites existing).将其元素从 `start``end``target` 位置复制到 **本身**(覆盖现有)。
721+
- [arr.copyWithin(target, start, end)](mdn:js/Array/copyWithin)将从 `start`(开始)位置到 `end`(结束)位置 [译注:不包含结束位元素] 的所有元素复制到 *自身*`target`(目标)位置中(覆盖现有元素)。
722722

723723
有关完整列表,请参阅[手册](mdn:js/Array)
724724

0 commit comments

Comments
 (0)