From 12a899ab8540bc84f56a0dc6491be80a48499d49 Mon Sep 17 00:00:00 2001
From: t7yang 你可以使用 你可以使用一個或多個的 本文假設您已經有點 JavaScript 的基礎,並且用 JavaScript 的函數創建過簡單的物件。 基於類的物件導向語言,比如 Java 和 C++,是建基於兩種概念之上:類和實例。 {{ note('術語 實例(instance)在 基於類的語言中具有特定的技術含義。在這些語言中,實例是指類的個體成員,與類有著根本性的不同。在 JavaScript 中,“實例”並不具有這種技術含義,因為 JavaScript 中不存在類和實例之間的這種差異。然而,在談論 JavaScript 時,“實例”可以非正式地用於表示用特定的建構函數創建的物件。所以,在這個例子中,你可以非正式地
+catch
區塊catch
區塊catch
區塊來處理 try
區塊可能丟出的例外。巢狀 try...catch 陳述式
+巢狀 try...catch 陳述式
try...catch
陳述式。 假如一個內層的try...catch
陳述式不具有 catch
區塊, 它將必須要有 finally
區塊與及封閉的 try...catch
陳述式來檢測是否有符合的例外。基於類 (Class-Based) 與 基於原型 (Prototype-Based) 語言的比較
+基於類 (Class-Based) 與 基於原型 (Prototype-Based) 語言的比較
jane
是 Engineer
的一個實例。與之類似,儘管術語父(parent),子(child),祖先(ancestor),和後代(descendant)在 JavaScript 中並沒有正式的含義,您可以非正式地使用這些術語用於指代原型鏈中處於更高層次或者更低層次的物件。') }}
Figure 8.4: Adding properties
到目前為止所展現的建構函數不允許在創建新的實例時指定屬性值。正如 Java 一樣,可以為建構函數提供參數以便初始化實例的屬性值。下圖展現其中一種做法。
- Figure 8.5: Specifying properties in a constructor, take 1
下面的表格中羅列了這些物件在 Java 和 JavaScript 中的定義。
diff --git a/files/zh-tw/web/javascript/guide/expressions_and_operators/index.html b/files/zh-tw/web/javascript/guide/expressions_and_operators/index.html index 0dcf129b93..df48ec6e8f 100644 --- a/files/zh-tw/web/javascript/guide/expressions_and_operators/index.html +++ b/files/zh-tw/web/javascript/guide/expressions_and_operators/index.html @@ -325,7 +325,7 @@ var var2 = 4; -概念上,位元邏輯運算子運作過程如下:
@@ -380,7 +380,7 @@ var var2 = 4;注意,在使用 位元NOT 運算子時, 所有的32個bit都被進行NOT了,包含最左邊用來描述正負數的位元(two's-complement representation)。
-位元移動運算子需要兩個運算元: 第一個是運算的目標,第二個是要移動的位元數。移動的方向取決於使用的運算子。
@@ -480,7 +480,7 @@ var n2 = !false; // !f 回傳 true var n3 = !'Cat'; // !t 回傳 false -邏輯運算式是由左向右解析的, 他們會以下列規則嘗試進行 短路解析:
@@ -522,7 +522,7 @@ mystring += '母'; // 得到 "字母" 並賦與給變數 mystring.這個陳述句會將 "成人" 賦與給變數 status
假如 age
大於等於18。 否則,會將 "小孩" 賦與給變數 status
。
逗點運算子 (,
) 作用是解析兩個運算元並回傳後面那個運算元的值。 這個運算子通常用於for迴圈內部,讓多個變數能在每次迴圈中被更新。
一元運算 是只需要一個運算元的運算。
-delete
delete
delete
運算子會刪除物件,物件的性質,或是陣列中指定 index 的物件。 語法是:
typeof
typeof
typeof
運算子 能以下列任一方式使用:
void
void
void
運算子 能以下列任一方式使用:
instanceof
instanceof
instanceof
運算子 在 指定物件 具有 指定的物件型態 時回傳 true。 語法是:
JavaScript 基本的關鍵字及運算式。
-this
this
this
關鍵字 能取得當前所在物件。 一般而言, this
能取得呼叫處所在的物件。 你可以使用 點 或是 中括號 來取用該物件中的特性:
左側是指定值的對象。
-new
new
你可以使用 new
運算子 來建立一個使用者自定義物件或內建物件的實例。 用法如下:
-
JavaScript 是個跨平台、物件導向、輕小型的腳本語言。作為獨立語言並不實用,而是為了能簡單嵌入其他產品和應用程式(例如:網頁瀏覽器)而設計。JavaScript 若寄宿在主體環境(Host environment)時,可以與環境中的物件 (Object)相連,並以程式控制這些物件。
@@ -41,7 +41,7 @@ translation_of: Web/JavaScript/Guide/IntroductionNetscape 公司發明了 JavaScript ,而 JavaScript 的第一次使用正是在 Netscape 自家的瀏覽器上。
-JavaScript 與 Java 在某些方面非常相似但本質上卻是不同的。 JavaScript 雖然和 Java 類似,卻沒有 Java 的靜態定型(static typing)及強型態確認(strong type checking)特性。 JavaScript 遵從大部份的 Java 表達式語法、命名傳統和基本的流程控制概念,這特性同時也是為何要將 LiveScript 重新命名為 JavaScript 的原因。
@@ -99,13 +99,13 @@ translation_of: Web/JavaScript/Guide/Introduction更多關於 JavaScript 和 Java 的差異比較,請參見 Details of the Object Model 。
-Netscape 公司發明了 JavaScript ,而 JavaScript 的第一次應用正是在 Netscape 瀏覽器。然而,Netscape 後來和 Ecma International(一個致力於將資訊及通訊系統標準化的歐洲組織,前身為 ECMA - 歐洲計算機製造商協會)合作,開發一個基於 JavaScript 核心並同時兼具標準化與國際化的程式語言,這個經過標準化的 JavaScript 便稱作 ECMAScript ,和 JavaScript 有著相同的應用方式並支援相關標準。各個公司都可以使用這個開放的標準語言去開發 JavaScript 的專案。ECMAScript 標準記載於 ECMA-262 這個規格中。
ECMA-262 標準同時也經過 ISO(國際標準化組織)認証,成為 ISO-16262 標準。你可以在 Mozilla 的網站上找到 PDF版本的ECMA-262,但這板本已過期;你也可以在 Ecma International 的網站 找到這個規格。 ECMAScript 規格中並沒有描述已經被 W3C(全球資訊網協會)標準化的文件物件模型(DOM)。文件物件模型定義了 HTML 文件物件(document objects)和腳本之間運作的方式。
-ECMAScript 規格(ECMA-262)在 Netscape 和 Ecma International 的密切合作下產生。下表描述了 JavaScript 的版本和 ECMAScript 的版本之間的關係。
@@ -162,13 +162,13 @@ translation_of: Web/JavaScript/Guide/IntroductionJavaScript 不僅相容於 ECMAScript 更提供了額外的特性。
-ECMAScript 規格是執行 ECMAScript 所必須的條件,當你想判斷某個 JavaScript 的特性是否在其他 ECMAScript 實作中有被支援時,ECMAScript 規格是非常有用的。如果你打算撰寫 JavaScript 程式碼並在程式碼中使用僅有 ECMAScript 所支援的特性,那你可能需要查閱一下 ECMAScript 規格。
ECMAScript 文件並不是為了幫助腳本程式設計師而撰寫,如果想知道撰寫腳本的相關資訊,請參考 JavaScript 使用說明。
-ECMAScript 規格使用的術語和語法對於 JavaScript 的程式設計師來說可能不是那麼的親切。雖然語言的描述在 ECMAScript 中可能會有所不同,但語言本身的性質仍然是不變的。JavaScript 支援所有在 ECMAScript 規格中被描述到的功能。
diff --git a/files/zh-tw/web/javascript/guide/regular_expressions/index.html b/files/zh-tw/web/javascript/guide/regular_expressions/index.html index f9b4235c2a..2d5983d163 100644 --- a/files/zh-tw/web/javascript/guide/regular_expressions/index.html +++ b/files/zh-tw/web/javascript/guide/regular_expressions/index.html @@ -54,7 +54,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions\
\
反斜線放在非特殊符號前面,使非特殊符號不會被逐字譯出,代表特殊作用。
例如:'b' 如果沒有 '\' 在前頭,功能是找出小寫 b;若改為 '\b' 則代表的是邊界功能,block 用意。
@@ -70,7 +70,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions
^
^
匹配輸入的開頭,如果 multiline flag 被設為 true,則會匹配換行字元後。
@@ -80,7 +80,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions$
$
匹配輸入的結尾,如果 multiline flag 被設為 true,則會匹配換行字元。
@@ -88,7 +88,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions*
*
匹配前一字元 0 至多次。
@@ -99,7 +99,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions
+
+
匹配前一字元 1 至多次,等同於 {1,}
。
?
?
匹配前一字元 0 至 1 次,等同於 {0,1}
。
.
.
(小數點)匹配除了換行符號之外的單一字元。
@@ -128,7 +128,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions(x)
(x)
Capturing Parentheses
@@ -141,7 +141,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions(?:x)
(?:x)
Non-Capturing Parentheses
@@ -166,7 +166,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressionsx(?=y)
x(?=y)
符合'x',且後接的是'y'。'y'為'x'存在的意義。
@@ -175,7 +175,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions
x(?!y)
x(?!y)
符合'x',且後接的不是'y'。'y'為否定'x'存在的意義,後面不行前功盡棄(negated lookahead)。
@@ -187,7 +187,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions
x|y
x|y
符合「x」或「y」。
@@ -195,7 +195,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions{n}
{n}
規定符號確切發生的次數,n為正整數
@@ -203,7 +203,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions{n,m}
{n,m}
搜尋條件:n為至少、m為至多,其n、m皆為正整數。若把m設定為0,則為Invalid regular expression。
@@ -211,13 +211,13 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions[xyz]
[xyz]
.
) 和米字號(*
),在字元集合中不具特殊意義,所以不需轉換。若要設一個字元範圍的集合,可以使用橫線 "-"
,如下例所示:[a-d]
等同於 [abcd]。
會匹配 "brisket" 的 "b" 、"city" 的 'c' ……等。 而/[a-z.]+/
和 /[\w.]+/
均可匹配字串 "test.i.ng" 。[^xyz]
[^xyz]
bracket中寫入的字元將被否定,匹配非出現在bracket中的符號。
可用 '-' 來界定字元的範圍。一般直接表達的符號都可以使用這種方式。
[\b]
[\b]
\b
\b
吻合文字邊界。A word boundary matches the position where a word character is not followed or preceded by another word-character. Note that a matched word boundary is not included in the match. In other words, the length of a matched word boundary is zero. (Not to be confused with [\b]
.)
\B
\B
吻合非文字邊界。This matches a position where the previous and next character are of the same type: Either both must be words, or both must be non-words. The beginning and end of a string are considered non-words.
@@ -252,7 +252,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions\cX
\cX
Where X is a character ranging from A to Z. Matches a control character in a string.
@@ -260,7 +260,7 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions\d
\d
吻合數字,寫法等同於 [0-9] 。
\D
\D
吻合非數字,寫法等同於 [^0-9]。
\f
\f
\n
\n
\r
\r
\s
\s
Matches a single white space character, including space, tab, form feed, line feed. Equivalent to [ \f\n\r\t\v\u00a0\u1680\u180e\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]
.
\S
\S
Matches a single character other than white space. Equivalent to [^ \f\n\r\t\v\u00a0\\u1680u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]
.
\t
\t
\v
\v
\w
\w
包含數字字母與底線,等同於[A-Za-z0-9_]。
\W
\W
Matches any non-word character. Equivalent to [^A-Za-z0-9_]
.
\n
\n
Where n is a positive integer, a back reference to the last substring matching the n parenthetical in the regular expression (counting left parentheses).
@@ -338,15 +338,15 @@ translation_of: Web/JavaScript/Guide/Regular_Expressions\0
\0
\0<digits>
is an octal escape sequence. Instead use \x00
.\xhh
\xhh
\uhhhh
\uhhhh
JavaScript has a number of predefined objects. In addition, you can create your own objects. You can create an object using an object initializer. Alternatively, you can first create a constructor function and then instantiate an object invoking that function in conjunction with the new
operator.
In addition to creating objects using a constructor function, you can create objects using an object initializer. Using object initializers is sometimes referred to as creating objects with literal notation. "Object initializer" is consistent with the terminology used by C++.
-- cgit v1.2.3-54-g00ecf