Skip to content

Commit 6cad200

Browse files
authored
Merge pull request BonsaiDen#383 from a90100/master
Fixed zhtw typo & translated chapter this into zhtw
2 parents 54ceed0 + 2c7a3a6 commit 6cad200

File tree

9 files changed

+29
-40
lines changed

9 files changed

+29
-40
lines changed

doc/zhtw/array/constructor.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
new Array('3') // 結果: ['3']
1111

1212
在上面的範例 `new Array(3)` 當只有一個參數傳入到 `Array` 的建構函數
13-
且那個參數事宜個數字,建構函數會回傳空值
13+
且那個參數是一個數字,建構函數會回傳空值
1414
但是 `Array` 長度的屬性會變成跟那個參數一樣(以此範例來看他回傳的長度為 3)
1515
**注意** 只有他長度的屬性會被設定,整個 Array裡面的數值都不會初始化
1616

doc/zhtw/array/general.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
> 只有 [objects](#object.general) 來管理建值的相對應關係
88
> Arrays 是**保持** 順序的,Objects **則沒有**
99
10-
因為 `for in` 迴圈會列舉所有在原型 Array 上的屬性因為他會使用[`hasOwnProperty`](#object.hasownproperty), 這會使得 Array 比原本的 `for` 迴圈慢上二十幾倍
10+
因為 `for in` 迴圈會使用[`hasOwnProperty`](#object.hasownproperty),所以它會列舉所有在原型 Array 上的屬性,這會使得 Array 比原本的 `for` 迴圈慢上二十幾倍
1111

1212
### 迴圈
1313

@@ -20,8 +20,8 @@
2020

2121
在上面的例子中利用 `l = list.length` 來處理 Array 的長度問題。
2222

23-
雖然 `length` 屬性是屬於 Array 中其中一個屬性,但是他還使有一定的性能消耗在每次循環的訪問
24-
近期 Javascript 使用 **may** 來解決在這上面的效率問題,但是在現在的引擎上還不一定有支援。
23+
雖然 `length` 屬性是屬於 Array 中其中一個屬性,但是他在每次循環還是有一定的性能消耗
24+
近期 Javascript **可能**使用來解決在這上面的效率問題,但是在現在的引擎上還不一定有支援。
2525

2626
實際上,不使用暫存 Array 長度的方式比使用暫存的版本還要慢很多。
2727

doc/zhtw/core/undefined.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## `undefined``null`
22

3-
JavaScript 中有兩個表示空值的方式, `null``undefined``undefined`式比較常用的一種
3+
JavaScript 中有兩個表示空值的方式, `null``undefined``undefined`是比較常用的一種
44

55
### `undefined` 的值
66

doc/zhtw/function/arguments.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
Array.prototype.slice.call(arguments);
2020

21-
這種轉化方式比較 ****不建議使用這種作法如果再追求效率的程式中
21+
這種轉化方式比較 ****如果在追求效率的程式中,不建議使用這種作法
2222

2323

2424
### 傳遞參數
@@ -53,7 +53,7 @@
5353

5454
`Arguments` 物件創造的 *getter**setter* 的函數方法,可以被視為原本函數的變數。
5555

56-
因此,改變了一個變數會跟著改變它的值而且也間接的改變稻香對應的 `arguments` 的物件,反之亦然。
56+
因此,改變了一個形式參將數會跟著改變對應的 `arguments` 的屬性,反之亦然。
5757

5858
function foo(a, b, c) {
5959
arguments[0] = 2;

doc/zhtw/function/scopes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ JavaScript 中所有的作用區,包括 *全域作用域*,都有一個特殊
160160

161161
1. 當作用域內是否有 `var foo` 的定義。
162162
2. 函式形式參數是否有使用 `foo` 名稱定義。
163-
3. 函式自身是剖叫做 `foo`
163+
3. 函式自身是否叫做 `foo`
164164
4. 回溯到上一個層級然後再從第一個開始往下去查。
165165

166166
> **注意: ** 自定義 `arguments` 參數會阻止原生的 `arguments` 的物件創立

doc/zhtw/function/this.md

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## `this` 的工作原理
22

3-
JavaScript 有移到完全部屬於其他語言處理 `this` 的處理機制。
3+
JavaScript 有一道完全不屬於其他語言處理 `this` 的處理機制。
44
**** 種不同的情況下, `this` 指向的各不相同
55

66
### 全域變數
@@ -42,65 +42,56 @@ JavaScript 有移到完全部屬於其他語言處理 `this` 的處理機制。
4242

4343
當使用 `function.prototype` 上的 `call` 或只 `apply` 方法時,函式內的 `this` 將會被 **顯示設置** 為函式調用的第一個參數。
4444

45-
As a result, in the above example the *method case* does **not** apply, and `this`
46-
inside of `foo` will be set to `bar`.
45+
因此,在以上的例子中已不適用*函式調用*的原則,而且`this`會被設定指向`bar`
4746

4847
> **Note:** `this` **cannot** be used to refer to the object inside of an `Object`
4948
> literal. So `var obj = {me: this}` will **not** result in `me` referring to
5049
> `obj`, since `this` only gets bound by one of the five listed cases.
5150
5251
### 常見誤解
5352

54-
While most of these cases make sense, the first can be considered another
55-
mis-design of the language because it **never** has any practical use.
53+
儘管大部分的例子都合理,但第一個例子(譯者注: 應該是指前面呼叫一個函式的那個例子)可以被視為一個語言的不良設計,因為它**從來**就沒有實際用途。
5654

5755
Foo.method = function() {
5856
function test() {
59-
// this is set to the global object
57+
// this 設定為全域
6058
}
6159
test();
6260
};
6361

64-
A common misconception is that `this` inside of `test` refers to `Foo`; while in
65-
fact, it **does not**.
62+
一個常見的誤解是 `test` 中的 `this` 指向 `Foo` 物件,但實際上並**不是**
6663

67-
In order to gain access to `Foo` from within `test`, it is necessary to create a
68-
local variable inside of `method` that refers to `Foo`.
64+
為了在 `test` 中使用 `Foo` 物件,我們需要在 `method` 函式内部建立一個區域變數指向 `Foo`
6965

7066
Foo.method = function() {
7167
var that = this;
7268
function test() {
73-
// Use that instead of this here
69+
// 這裡使用 that 而非 this
7470
}
7571
test();
7672
};
7773

78-
`that` is just a normal variable name, but it is commonly used for the reference to an
79-
outer `this`. In combination with [closures](#function.closures), it can also
80-
be used to pass `this` values around.
74+
`that` 只是普通的名字,不過這個名字常被用用來指向外部的 `this`。 在 [閉包](#function.closures) 一節,可以看到它(`that`)可以取代 `this` 傳遞。
8175

82-
As of ECMAScript 5 you can use the `bind` method combined with an anonymous function to achieve the same result.
76+
ECMAScript 5 ,你可以使用 `bind` 結合匿名函式達到相同結果。
8377

8478
Foo.method = function() {
8579
var test = function() {
86-
// this now refers to Foo
80+
// this 指向 Foo
8781
}.bind(this);
8882
test();
8983
};
9084

91-
### Assigning Methods
85+
### 函式表達式
9286

93-
Another thing that does **not** work in JavaScript is function aliasing, which is
94-
**assigning** a method to a variable.
87+
另一個在 JavaScript 中**不會**運作的就是 function aliasing,也就是函式**賦值**給一個變數。
9588

9689
var test = someObject.methodTest;
9790
test();
9891

99-
Due to the first case, `test` now acts like a plain function call; therefore,
100-
`this` inside it will no longer refer to `someObject`.
92+
上例中,`test` 就像一個普通的函式被调用;因此,函式内的 this 將不再指向 `someObject`
10193

102-
While the late binding of `this` might seem like a bad idea at first, in
103-
fact, it is what makes [prototypal inheritance](#object.prototype) work.
94+
雖然起初 `this` 的绑定特性似乎像是個壞主意,但事實上,它使得 [原型繼承](#object.prototype)得以運作。
10495

10596
function Foo() {}
10697
Foo.prototype.method = function() {};
@@ -110,7 +101,5 @@ fact, it is what makes [prototypal inheritance](#object.prototype) work.
110101

111102
new Bar().method();
112103

113-
When `method` gets called on an instance of `Bar`, `this` will now refer to that
114-
very instance.
115-
104+
`method` 被呼叫時,`this` 將會指向 `Bar` 的實體物件。
116105

doc/zhtw/object/general.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ JavaScript 的物件可以作為 [*Hashmaps*][1]使用,主要用來保存命
6969
只有 `baz` 真正被刪除而已,所以從輸出結果中消失。
7070

7171

72-
### 屬姓名的語法
72+
### 屬性名的語法
7373

7474
var test = {
7575
'case': 'I am a keyword, so I must be notated as a string',

doc/zhtw/types/instanceof.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## `instanceof` 操作符
22

3-
`instanceof` 操作符用來比較兩個建構函數的操作數。只有在比較字定義的物件時才有意義。這和 [typeof operator](#types.typeof)一樣用處不大。
3+
`instanceof` 操作符用來比較兩個建構函數的操作數。只有在比較自定義的物件時才有意義。這和 [typeof operator](#types.typeof)一樣用處不大。
44

55
### 比較定意義物件
66

@@ -24,7 +24,7 @@
2424
'foo' instanceof String; // false
2525
'foo' instanceof Object; // false
2626

27-
有一點需要注意的, `instanceof` 不能用來物件來自上下文不同的屬性(例如:瀏覽器中不同的文檔結構),因為它的建構函數不一樣。
27+
有一點需要注意的, `instanceof` 不會在來自不同的上下文的物件運作(例如:瀏覽器中不同的文檔結構),因為它的建構函數不一樣。
2828

2929
### In Conclusion
3030

doc/zhtw/types/typeof.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
`typeof` 操作符 (和
44
[`instanceof`](#types.instanceof)) 可能是最大的設計錯誤在 JavaScript,因為它幾乎不可能從它們那裡得到想要的結果。
55

6-
雖然 `instanceof` 還是有一些限制上的使用, `typeof` 只有一個實際上的運傭情形,但是 **不是** 用在檢查物件的類型。
6+
雖然 `instanceof` 還是有一些限制上的使用, `typeof` 只有一個實際上的運用情形,但是 **不是** 用在檢查物件的類型。
77

88
> **注意:** 由於 `typeof` 也可以像函式的語法被調用,例如 `typeof(obj)`,但這並是一個函數調用。
99
> 那兩個小括號只是用來計算一個表達式的值,這個返回值會作為 `typeof` 操作符的一個操作數。
@@ -67,8 +67,8 @@ JavaScript 標準文檔只給出了一種獲取 `[[Class]]` 值的方法,那
6767
### 結語
6868

6969
為了去檢查一個物件,強烈建議去使用 `Object.prototype.toString` 因為這是唯一可以依賴的方式。
70-
正如上面所看到的 `typeof` 的亦先返回值在標準文檔中未定義,因此不同的引擎可能不同。
70+
正如上面所看到的 `typeof` 的事先返回值在標準文檔中未定義,因此不同的引擎可能不同。
7171

72-
除非為了檢測一個變數是否定義,我們應該避免是用 `typeof` 操作符。
72+
除非為了檢測一個變數是否定義,我們應該避免使用 `typeof` 操作符。
7373

7474

0 commit comments

Comments
 (0)