Browse files

finished types/,

  • Loading branch information...
chilijung committed Mar 14, 2013
1 parent 7b6fb69 commit 0510d993c594ad5de81ee7e7eacce8717043a80f
Showing with 21 additions and 28 deletions.
  1. +15 −20 doc/zh-TW/types/
  2. +6 −8 doc/zh-TW/types/
@@ -16,49 +16,44 @@ JavaScript 是一個 *弱類型* 的程式語言,所以在 **任何** 情況
10 == 010;
10 == '-10';
-> **ES5 Note:** Number literals that start with a `0` are interpreted as octal
-> (Base 8). Octal support for these has been **removed** in ECMAScript 5 strict
-> mode.
+> **ES5 注意:** 如果數字字面值的開頭是 `0` 它會強制轉為八進位數字解析。
+> 而在 ES5 嚴格模式下,它已經被刪除了。
To avoid the issues above, use of the [strict equal operator](#types.equality)
is **highly** recommended. Although this avoids a lot of common pitfalls, there
are still many further issues that arise from JavaScript's weak typing system.
+為了去避免上驗的事件發生,我們會用 [嚴格等於操作符](#types.equality) 這是強烈建議。
+因為它可以避免很多常見的問題,但 JavaScript 的弱類型系同仍然會導致一些其他問題。
-### Constructors of Built-In Types
+### 內置類型的建構函式
-The constructors of the built in types like `Number` and `String` behave
-differently when being used with the `new` keyword and without it.
+內置類型(比如 `Number``String`)在被調用時,使用或不使用 `new` 的結果完全不同。
new Number(10) === 10; // False, Object and Number
Number(10) === 10; // True, Number and Number
new Number(10) + 0 === 10; // True, due to implicit conversion
-Using a built-in type like `Number` as a constructor will create a new `Number`
-object, but leaving out the `new` keyword will make the `Number` function behave
-like a converter.
+使用內置類型 `Number` 作為建構函式會建造一個新的 `Number` 物件,而在不使用 `new` 關鍵字的 `Number` 函式更像是一個數字轉換器。
-In addition, passing literals or non-object values will result in even more
-type coercion.
-The best option is to cast to one of the three possible types **explicitly**.
+最好的方式是比較值的 **顯示** 的轉換成最有可能的三種形態
-### Casting to a String
+### 轉換成字符串
'' + 10 === '10'; // true
-By prepending an empty string, a value can easily be cast to a string.
-### Casting to a Number
+### 轉換成一個數字
+'10' === 10; // true
-Using the **unary** plus operator, it is possible to cast to a number.
+使用 **一元** 的加號操作符,可以把字符串轉為數字。
-### Casting to a Boolean
-By using the **not** operator twice, a value can be converted a boolean.
+### 轉換成一個 Bool
+通過使用 **否** 操作符兩字,可以把一個值轉換為 Bool。
!!'foo'; // true
!!''; // false
@@ -1,19 +1,17 @@
-## The `typeof` Operator
+## `typeof` 操作符
-The `typeof` operator (together with
-[`instanceof`](#types.instanceof)) is probably the biggest
-design flaw of JavaScript, as it is almost **completely broken**.
+`typeof` 操作符 (和
+[`instanceof`](#types.instanceof)) 可能是最大的設計錯誤在 JavaScript,因為它幾乎不可能從它們那裡得到想要的結果。
-Although `instanceof` still has limited uses, `typeof` really has only one
-practical use case, which does **not** happen to be checking the type of an
+雖然 `instanceof` 還是有一些限制上的使用, `typeof` 只有一個實際上的運傭情形,但是 **不是** 用在檢查物件的類型。
> **Note:** While `typeof` can also be called with a function like syntax, i.e.
> `typeof(obj)`, this is not a function call. The parentheses behave as normal
> and the return value will be used as the operand of the `typeof` operator.
> There is **no** `typeof` function.
-### The JavaScript Type Table
+### JavaScript 類型表格
Value Class Type

0 comments on commit 0510d99

Please sign in to comment.