From f45e9e070c93ebbd83d488bdd775987a4d75c201 Mon Sep 17 00:00:00 2001 From: t7yang Date: Mon, 10 Jan 2022 08:38:08 +0800 Subject: fix yari h2m dry run errors --- .../a_re-introduction_to_javascript/index.html | 4 +- files/zh-tw/web/javascript/closures/index.html | 8 +- .../web/javascript/data_structures/index.html | 4 +- .../control_flow_and_error_handling/index.html | 6 +- .../guide/details_of_the_object_model/index.html | 24 +- .../guide/expressions_and_operators/index.html | 10 +- .../web/javascript/guide/functions/index.html | 6 +- .../javascript/guide/grammar_and_types/index.html | 8 +- files/zh-tw/web/javascript/guide/index.html | 250 +++++---- .../guide/indexed_collections/index.html | 14 +- .../web/javascript/guide/introduction/index.html | 2 +- .../guide/iterators_and_generators/index.html | 4 +- .../web/javascript/guide/using_promises/index.html | 6 +- .../guide/working_with_objects/index.html | 2 +- files/zh-tw/web/javascript/index.html | 8 +- .../inheritance_and_the_prototype_chain/index.html | 4 +- .../reference/classes/constructor/index.html | 90 +--- .../web/javascript/reference/classes/index.html | 69 +-- .../javascript/reference/classes/static/index.html | 70 +-- .../reference/errors/not_defined/index.html | 4 +- .../functions/arguments/callee/index.html | 82 +-- .../reference/functions/arguments/index.html | 12 +- .../functions/default_parameters/index.html | 108 +--- .../web/javascript/reference/functions/index.html | 137 +---- .../functions/method_definitions/index.html | 8 +- .../global_objects/array/concat/index.html | 2 +- .../global_objects/array/foreach/index.html | 8 +- .../reference/global_objects/array/index.html | 12 +- .../global_objects/array/indexof/index.html | 2 +- .../global_objects/array/reduce/index.html | 2 +- .../reference/global_objects/array/some/index.html | 4 +- .../global_objects/arraybuffer/index.html | 121 +---- .../global_objects/asyncfunction/index.html | 2 +- .../reference/global_objects/bigint/index.html | 31 +- .../reference/global_objects/boolean/index.html | 82 +-- .../reference/global_objects/dataview/index.html | 75 +-- .../global_objects/date/getday/index.html | 4 +- .../reference/global_objects/date/index.html | 112 +--- .../reference/global_objects/date/now/index.html | 75 +-- .../reference/global_objects/date/utc/index.html | 81 +-- .../global_objects/error/columnnumber/index.html | 50 +- .../reference/global_objects/error/index.html | 84 +-- .../global_objects/function/apply/index.html | 113 +--- .../global_objects/function/bind/index.html | 81 +-- .../global_objects/function/call/index.html | 14 +- .../reference/global_objects/function/index.html | 80 +-- .../global_objects/function/length/index.html | 97 +--- .../reference/global_objects/json/parse/index.html | 75 +-- .../global_objects/json/stringify/index.html | 51 +- .../reference/global_objects/math/index.html | 8 +- .../global_objects/math/random/index.html | 25 +- .../reference/global_objects/math/round/index.html | 73 +-- .../reference/global_objects/null/index.html | 80 +-- .../reference/global_objects/number/index.html | 88 +--- .../global_objects/number/toexponential/index.html | 84 +-- .../global_objects/object/create/index.html | 75 +-- .../object/defineproperties/index.html | 79 +-- .../object/defineproperty/index.html | 4 +- .../object/getprototypeof/index.html | 70 +-- .../object/hasownproperty/index.html | 75 +-- .../reference/global_objects/object/index.html | 80 +-- .../global_objects/object/keys/index.html | 75 +-- .../object/preventextensions/index.html | 98 +--- .../global_objects/object/proto/index.html | 4 +- .../global_objects/promise/finally/index.html | 4 +- .../reference/global_objects/promise/index.html | 14 +- .../global_objects/promise/then/index.html | 4 +- .../reference/global_objects/reflect/index.html | 74 +-- .../reference/global_objects/set/has/index.html | 4 +- .../reference/global_objects/string/index.html | 10 +- .../global_objects/string/padstart/index.html | 58 +-- .../global_objects/string/replace/index.html | 16 +- .../reference/global_objects/typedarray/index.html | 12 +- .../reference/global_objects/undefined/index.html | 8 +- files/zh-tw/web/javascript/reference/index.html | 570 ++++++++++++--------- .../reference/iteration_protocols/index.html | 4 +- .../reference/operators/await/index.html | 71 +-- .../reference/operators/comma_operator/index.html | 82 +-- .../operators/destructuring_assignment/index.html | 8 +- .../web/javascript/reference/operators/index.html | 4 +- .../operators/object_initializer/index.html | 171 +------ .../operators/operator_precedence/index.html | 2 +- .../operators/optional_chaining/index.html | 4 +- .../reference/operators/spread_syntax/index.html | 4 +- .../javascript/reference/operators/this/index.html | 12 +- .../reference/operators/typeof/index.html | 8 +- .../reference/statements/async_function/index.html | 8 +- .../reference/statements/block/index.html | 4 +- .../reference/statements/break/index.html | 8 +- .../reference/statements/debugger/index.html | 2 +- .../reference/statements/for...in/index.html | 8 +- .../reference/statements/label/index.html | 4 +- .../javascript/reference/statements/let/index.html | 6 +- .../reference/statements/return/index.html | 2 +- .../reference/statements/throw/index.html | 80 +-- .../javascript/reference/statements/var/index.html | 80 +-- .../javascript/reference/strict_mode/index.html | 8 +- files/zh-tw/web/javascript/typed_arrays/index.html | 79 +-- 98 files changed, 814 insertions(+), 3735 deletions(-) (limited to 'files/zh-tw/web/javascript') diff --git a/files/zh-tw/web/javascript/a_re-introduction_to_javascript/index.html b/files/zh-tw/web/javascript/a_re-introduction_to_javascript/index.html index fe062e2ba6..e563166720 100644 --- a/files/zh-tw/web/javascript/a_re-introduction_to_javascript/index.html +++ b/files/zh-tw/web/javascript/a_re-introduction_to_javascript/index.html @@ -896,7 +896,7 @@ y(7)

避免閉包還有另外一種方法:利用 window.onunload 事件消除相互參照。許多事件函示庫都會自動這麼做。

-
+

原始文件資訊

    @@ -906,5 +906,3 @@ y(7)
  • 更多資訊:其他關於這份教學的資訊(以及原作者所用的投影片)請前往原作者的網誌:Etech weblog
- -

 

diff --git a/files/zh-tw/web/javascript/closures/index.html b/files/zh-tw/web/javascript/closures/index.html index fbac2c5b07..de8cb67e54 100644 --- a/files/zh-tw/web/javascript/closures/index.html +++ b/files/zh-tw/web/javascript/closures/index.html @@ -164,8 +164,8 @@ console.log(counter.value()); // logs 1

這三個公有函式,皆為共享同一個環境的閉包。由於 JavaScript 的語法作用域,它們都能訪問 privateCounter 變數與 changeBy 函式。

-
-

你應該也發現到我們定義了建立 counter 的匿名函式、而我們接著呼叫它,並給counter 變數指派了回傳值。我們也能在分離的變數 makeCounter 儲存函式並用其建立數個 counter。

+
+

備註:你應該也發現到我們定義了建立 counter 的匿名函式、而我們接著呼叫它,並給counter 變數指派了回傳值。我們也能在分離的變數 makeCounter 儲存函式並用其建立數個 counter。

var makeCounter = function() {
@@ -199,8 +199,8 @@ alert(counter2.value()); /* Alerts 0 */
 
 

請注意 counter1counter2 這兩個計數器是如何維護其獨立性的。每個閉包都以各自的閉包,在參照不同版本的 privateCounter 變數。每當呼叫其中一個計數器時,它會透過該變數的數值變更,改變語法作用域的環境。不過,在其中一個閉包的變數值改時,其他閉包的數值並不會受到影響。

-
-

使用這種方法的閉包,提供了一些與物件導向程式設計的益處,尤其是資料隱藏與封裝。

+
+

備註:使用這種方法的閉包,提供了一些與物件導向程式設計的益處,尤其是資料隱藏與封裝。

在迴圈建立閉包:一個常見錯誤

diff --git a/files/zh-tw/web/javascript/data_structures/index.html b/files/zh-tw/web/javascript/data_structures/index.html index 83b215697f..0ff027ee5a 100644 --- a/files/zh-tw/web/javascript/data_structures/index.html +++ b/files/zh-tw/web/javascript/data_structures/index.html @@ -212,8 +212,8 @@ Infinity -
-

Note: Attribute is usually used by JavaScript engine, so you can't directly access it(see more about Object.defineProperty()).That's why the attribute is put in double square brackets instead of single.

+
+

備註:Attribute is usually used by JavaScript engine, so you can't directly access it(see more about Object.defineProperty()).That's why the attribute is put in double square brackets instead of single.

"Normal" objects, and functions

diff --git a/files/zh-tw/web/javascript/guide/control_flow_and_error_handling/index.html b/files/zh-tw/web/javascript/guide/control_flow_and_error_handling/index.html index c140d1a991..b26a576309 100644 --- a/files/zh-tw/web/javascript/guide/control_flow_and_error_handling/index.html +++ b/files/zh-tw/web/javascript/guide/control_flow_and_error_handling/index.html @@ -229,7 +229,9 @@ throw true; // True/False throw {toString: function() { return "我是物件!"; } };
-
備註:您可以在拋出例外時指定物件。 然後,可以在 catch 區塊中引用對象的屬性。
+
+

備註:您可以在拋出例外時指定物件。 然後,可以在 catch 區塊中引用對象的屬性。

+
// 創建類型爲 UserException 的物件
 function UserException(message) {
@@ -398,7 +400,7 @@ catch (e) {
  
  • settled:已完成,表示 Promise 狀態為已實現或已拒絕,但不是等待中。
  • -

    +

    promises

    使用 XHR 載入圖檔

    diff --git a/files/zh-tw/web/javascript/guide/details_of_the_object_model/index.html b/files/zh-tw/web/javascript/guide/details_of_the_object_model/index.html index ae69cc38f4..ba436da83c 100644 --- a/files/zh-tw/web/javascript/guide/details_of_the_object_model/index.html +++ b/files/zh-tw/web/javascript/guide/details_of_the_object_model/index.html @@ -40,7 +40,7 @@ translation_of: Web/JavaScript/Guide/Details_of_the_Object_Model

    下面的表格列出了上述區別。本節的後續部分將描述有關使用 JavaScript 構建函數和原型創建物件層級結構的詳細資訊,並與在 Java 中的做法做對比。

    - +
    @@ -80,7 +80,7 @@ translation_of: Web/JavaScript/Guide/Details_of_the_Object_Model

    本節的餘下部分將使用如下圖所示的僱員層級結構。

    -

    +

    圖例 8.1:一個簡單的物件層級

    @@ -102,7 +102,7 @@ translation_of: Web/JavaScript/Guide/Details_of_the_Object_Model

    在 真實的應用程式中,您很可能想定義允許在創建物件時給出屬性值的建構函數。(參見 更靈活的建構函數 獲得進一步的資訊)。對於現在而言,這些簡單的定義示範了繼承是如何發生的。

    -

    figure8.2.png
    +

    figure8.2.png
    圖例 8.2:Employee 物件定義

    以下 Employee 的 Java 和 JavaScript 的定義相類似。唯一的不同是在 Java 中需要指定每個屬性的類型,而在 JavaScript 中則不必指定,同時 Java 的類必須創建一個顯式的建構函數方法。

    @@ -238,8 +238,8 @@ public class Engineer extends WorkerBee {

    {{ note('術語 實例(instance)在 基於類的語言中具有特定的技術含義。在這些語言中,實例是指類的個體成員,與類有著根本性的不同。在 JavaScript 中,“實例”並不具有這種技術含義,因為 JavaScript 中不存在類和實例之間的這種差異。然而,在談論 JavaScript 時,“實例”可以非正式地用於表示用特定的建構函數創建的物件。所以,在這個例子中,你可以非正式地 janeEngineer 的一個實例。與之類似,儘管術語父(parent)子(child)祖先(ancestor),和後代(descendant)在 JavaScript 中並沒有正式的含義,您可以非正式地使用這些術語用於指代原型鏈中處於更高層次或者更低層次的物件。') }}

    -

    figure8.3.png
    - 圖例 8.3:通過簡單的定義創建物件

    +

    figure8.3.png
    + 圖例 8.3:通過簡單的定義創建物件

    物件的屬性

    @@ -285,15 +285,15 @@ mark.projects = ["navigator"];

    一旦 JavaScript 執行該語句,則 mark 物件也將具有 specialty 屬性,其值為 "none"。下圖展現了在 Employee 原型中添加該屬性,然後在 Engineer 的原型中重載該屬性的效果。

    -


    +


    Figure 8.4: Adding properties

    -

    更靈活的建構函數

    +

    更靈活的建構函數

    到目前為止所展現的建構函數不允許在創建新的實例時指定屬性值。正如 Java 一樣,可以為建構函數提供參數以便初始化實例的屬性值。下圖展現其中一種做法。

    -


    - Figure 8.5: Specifying properties in a constructor, take 1

    +


    + Figure 8.5: Specifying properties in a constructor, take 1

    下面的表格中羅列了這些物件在 Java 和 JavaScript 中的定義。

    @@ -413,7 +413,7 @@ jane.machine == "belau"

    到目前為止,建構函數已經能夠創建一個普通物件,然後為新物件指定本地的屬性和屬性值。您還可以通過直接調用原型鏈上的更高層次物件的建構函數,讓建構函數添加更多的屬性。下面的圖例展現這種新定義。

    -


    +


    Figure 8.6 Specifying properties in a constructor, take 2

    讓我們仔細看看這些定義的其中之一。以下是 Engineer 建構函數的定義:

    @@ -607,7 +607,9 @@ chris.__proto__.__proto__.__proto__.__proto__.__proto__ == null; } -
    Note: 在上面的實現中,檢查物件的類型是否為 "xml" 的目的在於解決新近版本的 JavaScript 中表達 XML 物件的特異之處。如果您想瞭解其中瑣碎細節,可以參考 {{ bug(634150) }}。
    +
    +

    備註: 在上面的實現中,檢查物件的類型是否為 "xml" 的目的在於解決新近版本的 JavaScript 中表達 XML 物件的特異之處。如果您想瞭解其中瑣碎細節,可以參考 {{ bug(634150) }}。

    +
    instanceOf (chris, Engineer)
     instanceOf (chris, WorkerBee)
    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 4e0c8655bc..77075cdd2e 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
    @@ -212,8 +212,8 @@ var var2 = 4;
      
     
    表 8.1 基於類(Java)和基於原型(JavaScript)的物件系統的比較
    -
    -

    筆記: (=>)不是運算子,是 箭頭函式。

    +
    +

    備註:(=>)不是運算子,是 箭頭函式。

    算術運算子

    @@ -226,7 +226,7 @@ var var2 = 4;

    除了標準的算術運算子外 (+, -, * /), JavaScript 提供以下表中的算術運算子:

    - +
    @@ -388,7 +388,7 @@ var var2 = 4;

    移動運算子在下表被列出.

    -
    算術運算子
    +
    @@ -421,7 +421,7 @@ var var2 = 4;

    邏輯運算子 通常被用於布林(邏輯)值; 使用於 布林(邏輯)值時, 它們會回傳布林型態的值。 然而,&&|| 運算子實際上是回傳兩指定運算元之一,因此用於非布林型態值時,它可能會回傳一個非布林型態的值。 邏輯運算子將在下表中被詳細解釋。

    -
    位元移動運算子
    +
    diff --git a/files/zh-tw/web/javascript/guide/functions/index.html b/files/zh-tw/web/javascript/guide/functions/index.html index f71ccfa1e9..af19983b6f 100644 --- a/files/zh-tw/web/javascript/guide/functions/index.html +++ b/files/zh-tw/web/javascript/guide/functions/index.html @@ -72,12 +72,8 @@ y = mycar.make; // y 的值還是 "Honda"
    var square = function(number) {return number * number};
     var x = square(4) //x 的值為 16
    -
    必要時,函式名稱可與函式表達式同時存在,並且可以用於在函式內部代指其本身(遞迴):
    -
     
    -
    -
    var factorial = function fac(n) {return n<2 ? 1 : n*fac(n-1)};
     
     console.log(factorial(3));
    @@ -150,7 +146,7 @@ e = factorial(5); // e gets the value 120
     
     

    There are other ways to call functions. There are often cases where a function needs to be called dynamically, or the number of arguments to a function vary, or in which the context of the function call needs to be set to a specific object determined at runtime. It turns out that functions are, themselves, objects, and these objects in turn have methods (see the Function object). One of these, the apply() method, can be used to achieve this goal.

    -

    Function scope

    +

    Function scope

    Variables defined inside a function cannot be accessed from anywhere outside the function, because the variable is defined only in the scope of the function. However, a function can access all variables and functions defined inside the scope in which it is defined. In other words, a function defined in the global scope can access all variables defined in the global scope. A function defined inside another function can also access all variables defined in it's parent function and any other variable to which the parent function has access.

    diff --git a/files/zh-tw/web/javascript/guide/grammar_and_types/index.html b/files/zh-tw/web/javascript/guide/grammar_and_types/index.html index 04f4818cdb..a5200c39ec 100644 --- a/files/zh-tw/web/javascript/guide/grammar_and_types/index.html +++ b/files/zh-tw/web/javascript/guide/grammar_and_types/index.html @@ -335,8 +335,8 @@ y = 42 + " is the answer" // "42 is the answer"
    var coffees = ['French Roast', 'Colombian', 'Kona'];
     
    -
    -

    Note : An array literal is a type of object initializer. See Using Object Initializers.

    +
    +

    Note: An array literal is a type of object initializer. See Using Object Initializers.

    If an array is created using a literal in a top-level script, JavaScript interprets the array each time it evaluates the expression containing the array literal. In addition, a literal used in a function is created each time the function is called.

    @@ -354,8 +354,8 @@ y = 42 + " is the answer" // "42 is the answer"

    If you include a trailing comma at the end of the list of elements, the comma is ignored. In the following example, the length of the array is three. There is no myList[3]. All other commas in the list indicate a new element.

    -
    -

    Note : Trailing commas can create errors in older browser versions and it is a best practice to remove them.

    +
    +

    Note: Trailing commas can create errors in older browser versions and it is a best practice to remove them.

    var myList = ['home', , 'school', ];
    diff --git a/files/zh-tw/web/javascript/guide/index.html b/files/zh-tw/web/javascript/guide/index.html
    index c7ba53958a..23d3b2a340 100644
    --- a/files/zh-tw/web/javascript/guide/index.html
    +++ b/files/zh-tw/web/javascript/guide/index.html
    @@ -11,106 +11,168 @@ translation_of: Web/JavaScript/Guide
     
     

    本指南區分成以下數個章節:

    -
    -
    -

    Note : in the above code, arrayLength must be a Number. Otherwise, an array with a single element (the provided value) will be created. Calling arr.length will return arrayLength, but the array actually contains empty (undefined) elements. Running a {{jsxref("Statements/for...in","for...in")}} loop on the array will return none of the array's elements.

    +
    +

    Note: in the above code, arrayLength must be a Number. Otherwise, an array with a single element (the provided value) will be created. Calling arr.length will return arrayLength, but the array actually contains empty (undefined) elements. Running a {{jsxref("Statements/for...in","for...in")}} loop on the array will return none of the array's elements.

    In addition to a newly defined variable as shown above, arrays can also be assigned as a property of a new or an existing object:

    @@ -79,8 +79,8 @@ emp[1] = 'Phil Lesh'; emp[2] = 'August West';
    -
    -

    Note : if you supply a non-integer value to the array operator in the code above, a property will be created in the object representing the array, instead of an array element.

    +
    +

    Note: if you supply a non-integer value to the array operator in the code above, a property will be created in the object representing the array, instead of an array element.

    var arr = [];
    @@ -104,8 +104,8 @@ var myArray = ['Mango', 'Apple', 'Orange'];
     
     

    You then refer to the first element of the array as myArray[0] and the second element of the array as myArray[1]. The index of the elements begins with zero.

    -
    -

    Note : the array operator (square brackets) is also used for accessing the array's properties (arrays are also objects in JavaScript). For example,

    +
    +

    Note: the array operator (square brackets) is also used for accessing the array's properties (arrays are also objects in JavaScript). For example,

    var arr = ['one', 'two', 'three'];
    @@ -433,7 +433,7 @@ Row 3: [3, 0] [3, 1] [3, 2] [3, 3]
     
     

    To achieve maximum flexibility and efficiency, JavaScript typed arrays split the implementation into buffers and views. A buffer (implemented by the {{jsxref("ArrayBuffer")}} object) is an object representing a chunk of data; it has no format to speak of, and offers no mechanism for accessing its contents. In order to access the memory contained in a buffer, you need to use a view. A view provides a context — that is, a data type, starting offset, and number of elements — that turns the data into an actual typed array.

    -

    Typed arrays in an ArrayBuffer

    +

    Typed arrays in an ArrayBuffer

    ArrayBuffer

    diff --git a/files/zh-tw/web/javascript/guide/introduction/index.html b/files/zh-tw/web/javascript/guide/introduction/index.html index ae980e77b0..fee75789ba 100644 --- a/files/zh-tw/web/javascript/guide/introduction/index.html +++ b/files/zh-tw/web/javascript/guide/introduction/index.html @@ -154,7 +154,7 @@ translation_of: Web/JavaScript/Guide/Introduction
    Logical operators
    -
    注意:ECMA-262 第2版是由已修正錯誤的第1版並加上些微的更動構成。現今由 Ecma International 的 TC39 工作組(TC39 Working Group)所發行的版本是 ECMAScript 5.1版
    +

    備註:ECMA-262 第2版是由已修正錯誤的第1版並加上些微的更動構成。現今由 Ecma International 的 TC39 工作組(TC39 Working Group)所發行的版本是 ECMAScript 5.1版

    JavaScript Reference 指出了哪些 JavaScript 的特性是相容於 ECMAScript 的。

    diff --git a/files/zh-tw/web/javascript/guide/iterators_and_generators/index.html b/files/zh-tw/web/javascript/guide/iterators_and_generators/index.html index 8c53a56eb2..5d5fb327c6 100644 --- a/files/zh-tw/web/javascript/guide/iterators_and_generators/index.html +++ b/files/zh-tw/web/javascript/guide/iterators_and_generators/index.html @@ -70,8 +70,8 @@ console.log("Iterated over sequence of size: ", result.value); // 5
    -
    -

    It is not possible to know reflectively whether a particular object is an iterator. If you need to do this, use Iterables.

    +
    +

    Note: It is not possible to know reflectively whether a particular object is an iterator. If you need to do this, use Iterables.

    Generator functions

    diff --git a/files/zh-tw/web/javascript/guide/using_promises/index.html b/files/zh-tw/web/javascript/guide/using_promises/index.html index 1df6376ffd..71b99084e7 100644 --- a/files/zh-tw/web/javascript/guide/using_promises/index.html +++ b/files/zh-tw/web/javascript/guide/using_promises/index.html @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Guide/Using_promises

    舉例來說,下方的範例若用舊方式應該會有兩個 Callback,並根據成功或失敗來決定使用哪個:

    -
    function successCallback(result) {
    +
    function successCallback(result) {
       console.log("It succeeded with " + result);
     }
     
    @@ -24,12 +24,12 @@ doSomething(successCallback, failureCallback);
     
     

    而新作法會回傳一個 Promise,這樣你就可以附加 Callback:

    -
    let promise = doSomething();
    +
    let promise = doSomething();
     promise.then(successCallback, failureCallback);

    再簡單點:

    -
    doSomething().then(successCallback, failureCallback);
    +
    doSomething().then(successCallback, failureCallback);

    我們稱之為 非同步函數呼叫。這個做法有許多好處,我們接下來看看。

    diff --git a/files/zh-tw/web/javascript/guide/working_with_objects/index.html b/files/zh-tw/web/javascript/guide/working_with_objects/index.html index ec531a1004..31b9403a01 100644 --- a/files/zh-tw/web/javascript/guide/working_with_objects/index.html +++ b/files/zh-tw/web/javascript/guide/working_with_objects/index.html @@ -124,7 +124,7 @@ myCar.year = 1969

    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.

    -

    Using object initializers

    +

    Using object initializers

    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++.

    diff --git a/files/zh-tw/web/javascript/index.html b/files/zh-tw/web/javascript/index.html index cc2b91de2e..13304860e0 100644 --- a/files/zh-tw/web/javascript/index.html +++ b/files/zh-tw/web/javascript/index.html @@ -20,8 +20,6 @@ translation_of: Web/JavaScript

    別搞混了 JavaScript 和 Java 程式語言。雖然 "Java" 和 "JavaScript" 都是 Oracle 公司在美國和其他國家的商標或註冊商標,但兩個語言有著非常不同的語法、語意和用途。

    -
    -

    教學

    透過指南和教學來學習編寫 JavaScript。

    @@ -77,9 +75,7 @@ translation_of: Web/JavaScript
    併行模組和事件循環
    JavaScript 具有基於「事件循環」的併行模組。
    -
    -

    參考

    瀏覽完整的 JavaScript 參考文件

    @@ -104,7 +100,7 @@ translation_of: Web/JavaScript
    程式碼速記本 (Scratchpad)網頁主控台 (Web Console)JavaScript 效能分析器(JavaScript Profiler)除錯器 (Debugger) 等等。
    JavaScript Shell
    JavaScript Shell 讓你更快的測試片段的 JavaScript。
    -
    TogetherJSPaste
    +
    TogetherJSPaste
    合作更簡單了。藉著在你的網站增加 TogetherJS,你的用戶們能在網站上互助 in real time!
    Stack Overflow
    Stack Overflow 上有關 JavaScript 的問題。
    @@ -113,5 +109,3 @@ translation_of: Web/JavaScript
    JSFiddle
    編輯 JavaScript、CSS、HTML 並取得及時結果。可以使用外部資源和與在線上與你的夥伴協作。
    -
    -
    diff --git a/files/zh-tw/web/javascript/inheritance_and_the_prototype_chain/index.html b/files/zh-tw/web/javascript/inheritance_and_the_prototype_chain/index.html index 744f6d9575..cf6d52ebd5 100644 --- a/files/zh-tw/web/javascript/inheritance_and_the_prototype_chain/index.html +++ b/files/zh-tw/web/javascript/inheritance_and_the_prototype_chain/index.html @@ -19,8 +19,8 @@ translation_of: Web/JavaScript/Inheritance_and_the_prototype_chain

    JavaScript 物件是一「包」動態的屬性(也就是它自己的屬性)並擁有一個原型物件的鏈結,當物件試圖存取一個物件的屬性時,其不僅會尋找該物件,也會尋找該物件的原型、原型的原型……直到找到相符合的屬性,或是到達原型鏈的尾端。

    -
    -

    遵照 ECMAScript 標準的 someObject.[[Prototype]] 標記,用於指派 someObject 的原型。從 ECMAScript 2015 開始, [[Prototype]] 使用 {{jsxref("Object.getPrototypeOf()")}} 與 {{jsxref("Object.setPrototypeOf()")}} 這兩個訪問器(accessors)訪問,等同於非標準,但各大瀏覽器已實做的 __proto__ 屬性。

    +
    +

    備註:遵照 ECMAScript 標準的 someObject.[[Prototype]] 標記,用於指派 someObject 的原型。從 ECMAScript 2015 開始, [[Prototype]] 使用 {{jsxref("Object.getPrototypeOf()")}} 與 {{jsxref("Object.setPrototypeOf()")}} 這兩個訪問器(accessors)訪問,等同於非標準,但各大瀏覽器已實做的 __proto__ 屬性。

    不要把 someObject.[[Prototype]] 與函式屬性 func.prototype 混淆了。它在函式被用作建構子的時候,指定 [[Prototype]] 要分派到所有由給定函式建立的物件實例(instance)。Object.prototype 屬性代表了原型屬性 {{jsxref("Object")}}。

    diff --git a/files/zh-tw/web/javascript/reference/classes/constructor/index.html b/files/zh-tw/web/javascript/reference/classes/constructor/index.html index 2d349f8b4e..11ff5315b1 100644 --- a/files/zh-tw/web/javascript/reference/classes/constructor/index.html +++ b/files/zh-tw/web/javascript/reference/classes/constructor/index.html @@ -55,97 +55,11 @@ translation_of: Web/JavaScript/Reference/Classes/constructor

    規範

    - - - - - - - - - - - - - - - - - - -
    規範狀態註解
    {{SpecName('ES2015', '#sec-static-semantics-constructormethod', 'Constructor Method')}}{{Spec2('ES2015')}}Initial definition.
    {{SpecName('ESDraft', '#sec-static-semantics-constructormethod', 'Constructor Method')}}{{Spec2('ESDraft')}}
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    功能ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支援{{CompatChrome(42.0)}}{{CompatGeckoDesktop(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    預設的建構子{{CompatUnknown}}{{CompatGeckoDesktop(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    功能AndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
    基本支援{{CompatNo}}{{CompatChrome(42.0)}}{{CompatGeckoMobile(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatChrome(42.0)}}
    預設的建構子{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/classes/index.html b/files/zh-tw/web/javascript/reference/classes/index.html index 06ea8d5719..6b49150746 100644 --- a/files/zh-tw/web/javascript/reference/classes/index.html +++ b/files/zh-tw/web/javascript/reference/classes/index.html @@ -279,76 +279,11 @@ l.speak();

    規格

    - - - - - - - - - - - - - -
    規格狀態評論
    {{SpecName('ES6', '#sec-class-definitions', 'Class definitions')}}{{Spec2('ES6')}}Initial definition.
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)EdgeInternet ExplorerOperaSafari
    Basic support{{CompatChrome(42.0)}}[1]
    - {{CompatChrome(49.0)}}
    {{CompatGeckoDesktop(45)}}13{{CompatNo}}{{CompatNo}}{{CompatSafari(9.0)}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
    Basic support{{CompatNo}}{{CompatGeckoMobile(45)}}{{CompatUnknown}}{{CompatUnknown}}9{{CompatChrome(42.0)}}[1]
    - {{CompatChrome(49.0)}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/classes/static/index.html b/files/zh-tw/web/javascript/reference/classes/static/index.html index 77faa35833..de1ab29004 100644 --- a/files/zh-tw/web/javascript/reference/classes/static/index.html +++ b/files/zh-tw/web/javascript/reference/classes/static/index.html @@ -42,77 +42,11 @@ console.log(tp.triple()); // 'tp.triple is not a function'.

    規格

    - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES6', '#sec-class-definitions', 'Class definitions')}}{{Spec2('ES6')}}Initial definition.
    {{SpecName('ESDraft', '#sec-class-definitions', 'Class definitions')}}{{Spec2('ESDraft')}}
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(42.0)}}{{CompatGeckoDesktop(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
    Basic support{{CompatNo}}{{CompatGeckoMobile(45)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatChrome(42.0)}}
    -
    +{{Compat}}

    你可能會需要看看

    diff --git a/files/zh-tw/web/javascript/reference/errors/not_defined/index.html b/files/zh-tw/web/javascript/reference/errors/not_defined/index.html index fa79033977..8ce779db84 100644 --- a/files/zh-tw/web/javascript/reference/errors/not_defined/index.html +++ b/files/zh-tw/web/javascript/reference/errors/not_defined/index.html @@ -18,8 +18,8 @@ translation_of: Web/JavaScript/Reference/Errors/Not_defined

    有個地方參照到不存在的變數了。這個變數需要宣告、或確定在目前腳本、或在 {{Glossary("scope")}} 裡可用。

    -
    -

    注意:如果要使用函式庫(例如 jQuery)的話,請確定在你使用諸如 $ 這樣的函式庫變數前,就已載入完畢。把載入函式庫的 {{HTMLElement("script")}} 標籤,放在你使用的程式碼之前。 +

    +

    備註:如果要使用函式庫(例如 jQuery)的話,請確定在你使用諸如 $ 這樣的函式庫變數前,就已載入完畢。把載入函式庫的 {{HTMLElement("script")}} 標籤,放在你使用的程式碼之前。

    diff --git a/files/zh-tw/web/javascript/reference/functions/arguments/callee/index.html b/files/zh-tw/web/javascript/reference/functions/arguments/callee/index.html index fe8b1dcda3..fa0a7fe9ab 100644 --- a/files/zh-tw/web/javascript/reference/functions/arguments/callee/index.html +++ b/files/zh-tw/web/javascript/reference/functions/arguments/callee/index.html @@ -11,7 +11,7 @@ translation_of: Web/JavaScript/Reference/Functions/arguments/callee

    callee is a property of the arguments object. It can be used to refer to the currently executing function inside the function body of that function. This is useful when the name of the function is unknown, such as within a function expression with no name (also called "anonymous functions").

    -
    Warning: The 5th edition of ECMAScript (ES5) forbids use of arguments.callee() in strict mode. Avoid using arguments.callee() by either giving function expressions a name or use a function declaration where a function must call itself.
    +

    Warning: The 5th edition of ECMAScript (ES5) forbids use of arguments.callee() in strict mode. Avoid using arguments.callee() by either giving function expressions a name or use a function declaration where a function must call itself.

    Why was arguments.callee removed from ES5 strict mode?

    @@ -108,87 +108,11 @@ john();

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.2
    {{SpecName('ES5.1', '#sec-10.6', 'Arguments Object')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-arguments-exotic-objects', 'Arguments Exotic Objects')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/functions/arguments/index.html b/files/zh-tw/web/javascript/reference/functions/arguments/index.html index ddccefae10..3a670e1f3c 100644 --- a/files/zh-tw/web/javascript/reference/functions/arguments/index.html +++ b/files/zh-tw/web/javascript/reference/functions/arguments/index.html @@ -20,12 +20,12 @@ translation_of: Web/JavaScript/Reference/Functions/arguments

    描述

    -
    -

    Note: 如果你有在使用 ES6 語法,建議參考其餘參數

    +
    +

    備註:如果你有在使用 ES6 語法,建議參考其餘參數

    -
    -

    Note: 「類陣列 (Array-like)」 的意思是 arguments 一樣擁有 length這項屬性,以及從 0 開始的索引,但是它沒有陣列內建的方法像是 forEach() ,或是 map() 。

    +
    +

    備註:「類陣列 (Array-like)」 的意思是 arguments 一樣擁有 length這項屬性,以及從 0 開始的索引,但是它沒有陣列內建的方法像是 forEach() ,或是 map() 。

    The arguments object is a local variable available within all (non-arrow) functions. You can refer to a function's arguments within the function by using the arguments object. This object contains an entry for each argument passed to the function, the first entry's index starting at 0.

    @@ -52,8 +52,8 @@ var args = [].slice.call(arguments); const args = Array.from(arguments); -
    -

    Using slice on arguments prevents optimizations in some JavaScript engines (V8 for example - more information). If you care for them, try constructing a new array by iterating through the arguments object instead. An alternative would be to use the despised Array constructor as a function:

    +
    +

    警告:Using slice on arguments prevents optimizations in some JavaScript engines (V8 for example - more information). If you care for them, try constructing a new array by iterating through the arguments object instead. An alternative would be to use the despised Array constructor as a function:

    var args = (arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments));
    diff --git a/files/zh-tw/web/javascript/reference/functions/default_parameters/index.html b/files/zh-tw/web/javascript/reference/functions/default_parameters/index.html index 1f37ee85c0..73bc901464 100644 --- a/files/zh-tw/web/javascript/reference/functions/default_parameters/index.html +++ b/files/zh-tw/web/javascript/reference/functions/default_parameters/index.html @@ -175,115 +175,11 @@ f(); // 6

    Specifications

    - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES2015', '#sec-function-definitions', 'Function Definitions')}}{{Spec2('ES2015')}}Initial definition.
    {{SpecName('ESDraft', '#sec-function-definitions', 'Function Definitions')}}{{Spec2('ESDraft')}}
    +{{Specifications}}

    瀏覽器的兼容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    功能特徵ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支援{{CompatChrome(49)}}{{CompatGeckoDesktop("15.0")}}Edge{{CompatNo}}{{CompatSafari(10)}}
    Parameters without defaults after default parameters{{CompatChrome(49)}}{{CompatGeckoDesktop("26.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatSafari(10)}}
    Destructured parameter with default value assignment{{CompatChrome(49)}}{{CompatGeckoDesktop("41.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    功能特徵AndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
    基本支援{{CompatNo}}{{CompatChrome(49)}}{{CompatGeckoMobile("15.0")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatChrome(49)}}
    Parameters without defaults after default parameters{{CompatNo}}{{CompatChrome(49)}}{{CompatGeckoMobile("26.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatChrome(49)}}
    Destructured parameter with default value assignment{{CompatNo}}{{CompatUnknown}}{{CompatGeckoMobile("41.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    要不要也看看

    diff --git a/files/zh-tw/web/javascript/reference/functions/index.html b/files/zh-tw/web/javascript/reference/functions/index.html index 0d64fa570a..464a1f311e 100644 --- a/files/zh-tw/web/javascript/reference/functions/index.html +++ b/files/zh-tw/web/javascript/reference/functions/index.html @@ -100,7 +100,7 @@ function myFunc(theObject) {

    The generator function declaration (function* statement)

    -
    +

    Note: Generator function are an experimental technology, part of the ECMAScript 6 proposal, and are not widely supported by browsers yet.

    @@ -122,7 +122,7 @@ function myFunc(theObject) {

    The generator function expression (function* expression)

    -
    +

    Note: Generator function are an experimental technology, part of the ECMAScript 6 proposal, and are not widely supported by browsers yet.

    @@ -145,7 +145,7 @@ function myFunc(theObject) {

    箭頭函式 The arrow function expression (=>)

    -
    +

    Note: Arrow function expressions are an experimental technology, part of the ECMAScript 6 proposal, and are not widely supported by browsers yet.

    @@ -167,7 +167,7 @@ param => expression

    The Function constructor

    -
    +

    Note: Using the Function constructor to create functions is not recommended since it needs the function body as a string which may prevent some JS engine optimizations and can also cause other problems.

    @@ -187,15 +187,15 @@ param => expression

    The GeneratorFunction constructor

    -
    +

    Note: Arrow function expressions are an experimental technology, part of the ECMAScript 6 proposal, and are not widely supported by browsers yet.

    -
    +

    Note: GeneratorFunction is not a global object, but could be obtained from generator function instance (see {{jsxref("GeneratorFunction")}} for more detail).

    -
    +

    Note: Using the GeneratorFunction constructor to create functions is not recommended since it needs the function body as a string which may prevent some JS engine optimizations and can also cause other problems.

    @@ -215,7 +215,7 @@ param => expression

    Function parameters

    -
    +

    Note: Default and rest parameters are experimental technology, part of the ECMAScript 6 proposal, and are not widely supported by browsers yet.

    @@ -255,7 +255,7 @@ param => expression

    Method definition syntax

    -
    +

    Note: Method definitions are experimental technology, part of the ECMAScript 6 proposal, and are not widely supported by browsers yet.

    @@ -453,126 +453,11 @@ result = padZeros(5,4); // returns "0005"

    Specifications

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    ECMAScript 1st Edition.StandardInitial definition. Implemented in JavaScript 1.0
    {{SpecName('ES5.1', '#sec-13', 'Function Definition')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-function-definitions', 'Function definitions')}}{{Spec2('ES6')}}New: Arrow functions, Generator functions, default parameters, rest parameters
    {{SpecName('ES6', '#', 'function*')}}{{Spec2('ES6')}}Initial definition.
    {{SpecName('ES6', '#sec-arrow-function-definitions', 'Arrow Function Definitions')}}{{Spec2('ES6')}}Initial definition.
    +{{Specifications}}

    Browser compatibility

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    Generator function39{{CompatGeckoDesktop("26.0")}}{{CompatUnknown}}26{{CompatUnknown}}
    Arrow function{{CompatNo}}{{CompatGeckoDesktop("22.0")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    Generator function{{CompatUnknown}}39{{CompatGeckoMobile("26.0")}}{{CompatUnknown}}26{{CompatUnknown}}
    Arrow function{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("22.0")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    See also

    diff --git a/files/zh-tw/web/javascript/reference/functions/method_definitions/index.html b/files/zh-tw/web/javascript/reference/functions/method_definitions/index.html index 15aeef0f00..b56c884503 100644 --- a/files/zh-tw/web/javascript/reference/functions/method_definitions/index.html +++ b/files/zh-tw/web/javascript/reference/functions/method_definitions/index.html @@ -69,7 +69,7 @@ translation_of: Web/JavaScript/Reference/Functions/Method_definitions -
    // Using a named property
    +
    // Using a named property
     var obj2 = {
       g: function* () {
         var index = 0;
    @@ -95,7 +95,7 @@ console.log(it.next().value); // 1

    {{jsxref("Statements/async_function", "Async 方法", "", 1)}} 也可以透過簡短語法定義。

    -
    // Using a named property
    +
    // Using a named property
     var obj3 = {
       f: async function () {
         await some_promise;
    @@ -150,7 +150,7 @@ new obj.g; // TypeError: obj.g is not a constructor (changed in ES2016)
     
     

    Simple test case

    -
    var obj = {
    +
    var obj = {
       a: 'foo',
       b() { return this.a; }
     };
    @@ -161,7 +161,7 @@ console.log(obj.b()); // "foo"
     
     

    The shorthand syntax also supports computed property names.

    -
    var bar = {
    +
    var bar = {
       foo0: function() { return 0; },
       foo1() { return 1; },
       ['foo' + 2]() { return 2; }
    diff --git a/files/zh-tw/web/javascript/reference/global_objects/array/concat/index.html b/files/zh-tw/web/javascript/reference/global_objects/array/concat/index.html
    index c8fc9a7aca..45730b8fad 100644
    --- a/files/zh-tw/web/javascript/reference/global_objects/array/concat/index.html
    +++ b/files/zh-tw/web/javascript/reference/global_objects/array/concat/index.html
    @@ -44,7 +44,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/concat
      
  • 資料型態為字串、數值或是布林(非 {{jsxref("Global_Objects/String", "String")}}、{{jsxref("Global_Objects/Number", "Number")}} 及 {{jsxref("Global_Objects/Boolean", "Boolean")}} 物件):concat 複製字串及數值的值到新的陣列。
  • -
    +

    備註:合併(多個)陣列/(多個)值將讓原始的陣列不會被受到影響。此外,任何對新陣列(只有在元素不是物件參考的情況下)的操作都不會影響原始的陣列,反之亦然。

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/array/foreach/index.html b/files/zh-tw/web/javascript/reference/global_objects/array/foreach/index.html index df1dc91684..d1f4b27a23 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/array/foreach/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/array/foreach/index.html @@ -66,8 +66,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/forEach

    forEach() does not mutate the array on which it is called (although callback, if invoked, may do so).

    -
    -

    除非是拋出異常,否則並沒有中止 forEach() 迴圈的辦法。如果你需要這樣做,forEach() 就是錯誤的用法,相反的,應該要用簡單的迴圈。如果你要測試陣列裡面的元素並回傳布林值,可以用 {{jsxref("Array.prototype.every()", "every()")}} 或 {{jsxref("Array.prototype.some()", "some()")}}。如果可以的話,新的方法 {{jsxref("Array.prototype.find()", "find()")}} 或 {{jsxref("Array.prototype.findIndex()", "findIndex()")}} 也可以用於 true 值之後提前終止。

    +
    +

    備註:除非是拋出異常,否則並沒有中止 forEach() 迴圈的辦法。如果你需要這樣做,forEach() 就是錯誤的用法,相反的,應該要用簡單的迴圈。如果你要測試陣列裡面的元素並回傳布林值,可以用 {{jsxref("Array.prototype.every()", "every()")}} 或 {{jsxref("Array.prototype.some()", "some()")}}。如果可以的話,新的方法 {{jsxref("Array.prototype.find()", "find()")}} 或 {{jsxref("Array.prototype.findIndex()", "findIndex()")}} 也可以用於 true 值之後提前終止。

    範例

    @@ -140,8 +140,8 @@ obj.sum;

    Since the thisArg parameter (this) is provided to forEach(), it is passed to callback each time it's invoked, for use as its this value.

    -
    -

    If passing the function argument using an arrow function expression the thisArg parameter can be omitted as arrow functions lexically bind the {{jsxref("Operators/this", "this")}} value.

    +
    +

    Note: If passing the function argument using an arrow function expression the thisArg parameter can be omitted as arrow functions lexically bind the {{jsxref("Operators/this", "this")}} value.

    An object copy function

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/array/index.html b/files/zh-tw/web/javascript/reference/global_objects/array/index.html index f6c64c360c..112a5d1e21 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/array/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/array/index.html @@ -215,12 +215,12 @@ var myArray = myRe.exec('cdbBdbsbz');

    這項比對結果的屬性與元素參考如下:

    - +
    - - - + + + @@ -292,8 +292,8 @@ var myArray = myRe.exec('cdbBdbsbz');

    Array 泛型方法

    -
    -

    泛型陣列並非標準且已被棄用,將會在不久之後被去除。 

    +
    +

    警告:泛型陣列並非標準且已被棄用,將會在不久之後被去除。

    有時你想將陣列方法用於字串或其他類陣列物件(像是函數 {{jsxref("Functions/arguments", "arguments", "", 1)}})。藉此操作,你將此字串視為由字元組成的陣列(反之為將其他非陣列視為物件)。如範例,若要確認字串中的每個字元是不是字母,你可能會這樣寫:

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/array/indexof/index.html b/files/zh-tw/web/javascript/reference/global_objects/array/indexof/index.html index ff6bbdba76..960e15896d 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/array/indexof/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/array/indexof/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/indexOf

    indexOf() 方法會回傳給定元素於陣列中第一個被找到之索引,若不存在於陣列中則回傳 -1。

    -
    +

    備註:若是調用字串的方法,請參閱 {{jsxref("String.prototype.indexOf()")}}。

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/array/reduce/index.html b/files/zh-tw/web/javascript/reference/global_objects/array/reduce/index.html index 1f943d8dfa..b2caccdef9 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/array/reduce/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/array/reduce/index.html @@ -58,7 +58,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/Reduce

    當回呼函式第一次被呼叫時,accumulatorcurrentValue 的值可能為兩種不同的狀況:若在呼叫 reduce() 時有提供 initialValue,則 accumulator 將會等於 initialValue,且 currentValue 會等於陣列中的第一個元素值;若沒有提供 initialValue,則 accumulator 會等於陣列的第一個元素值,且 currentValue 將會等於陣列的第二個元素值。

    -
    +

    備註:假如 initialValue 未被提供,reduce() 將會跳過第一個陣列索引,從陣列索引 1 開始執行回呼函式。若有提供 initialValue,則會由陣列索引 0 開始執行。

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/array/some/index.html b/files/zh-tw/web/javascript/reference/global_objects/array/some/index.html index 7dd0fbdf34..4f6207b9a7 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/array/some/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/array/some/index.html @@ -16,8 +16,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Array/some
    {{EmbedInteractiveExample("pages/js/array-some.html")}}
    -
    -

    注意:如果輸入空陣列的話,這個方法會回傳 false

    +
    +

    備註:如果輸入空陣列的話,這個方法會回傳 false

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/arraybuffer/index.html b/files/zh-tw/web/javascript/reference/global_objects/arraybuffer/index.html index 6882aaf6ec..5c77343325 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/arraybuffer/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/arraybuffer/index.html @@ -56,7 +56,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/ArrayBuffer
    Returns true if arg is one of the ArrayBuffer views, such as typed array objects or a {{jsxref("DataView")}}. Returns false otherwise.
    {{jsxref("ArrayBuffer.transfer", "ArrayBuffer.transfer(oldBuffer [, newByteLength])")}} {{experimental_inline}}
    -
    Returns a new ArrayBuffer whose contents are taken from the oldBuffer's data and then is either truncated or zero-extended by newByteLength.
    +
    Returns a new ArrayBuffer whose contents are taken from the oldBuffer's data and then is either truncated or zero-extended by newByteLength.
    @@ -86,126 +86,11 @@ var view = new Int32Array(buffer);

    規範

    -
    屬性/元素說明範例屬性/元素說明範例
    input
    - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('Typed Array')}}{{Spec2('Typed Array')}}Superseded by ECMAScript 6.
    {{SpecName('ES6', '#sec-arraybuffer-constructor', 'ArrayBuffer')}}{{Spec2('ES6')}}Initial definition in an ECMA standard. Specified that new is required.
    {{SpecName('ESDraft', '#sec-arraybuffer-constructor', 'ArrayBuffer')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support7.0{{CompatVersionUnknown}}{{CompatGeckoDesktop("2")}}1011.65.1
    ArrayBuffer() without new throws{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoDesktop("44")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    ArrayBuffer.slice() {{non-standard_inline}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    - {{CompatNo}} {{CompatGeckoDesktop("53")}}
    {{CompatNo}}{{CompatNo}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support4.0{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("2")}}1011.64.2
    ArrayBuffer() without new throws{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("44")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    ArrayBuffer.slice() {{non-standard_inline}}{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    - {{CompatNo}} {{CompatGeckoMobile("53")}}
    {{CompatNo}}{{CompatNo}}{{CompatUnknown}}
    -
    +{{Compat}}

    相容性備註

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/asyncfunction/index.html b/files/zh-tw/web/javascript/reference/global_objects/asyncfunction/index.html index c25f3ee3a1..8890a3bc65 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/asyncfunction/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/asyncfunction/index.html @@ -31,7 +31,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/AsyncFunction

    All arguments passed to the function are treated as the names of the identifiers of the parameters in the function to be created, in the order in which they are passed.

    -
    +

    Note: {{jsxref("Statements/async_function", "async functions")}} created with the AsyncFunction constructor do not create closures to their creation contexts; they are always created in the global scope. When running them, they will only be able to access their own local variables and global ones, not the ones from the scope in which the AsyncFunction constructor was called. This is different from using {{jsxref("Global_Objects/eval", "eval")}} with code for an async function expression.

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/bigint/index.html b/files/zh-tw/web/javascript/reference/global_objects/bigint/index.html index 35ccd60a0b..2e62e69184 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/bigint/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/bigint/index.html @@ -19,8 +19,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/BigInt
    欲創建的數值,可以為整數或字串。
    -
    -

    Note: BigInt() 不和 {{JSxRef("Operators/new", "new")}} 一起使用。

    +
    +

    Note: BigInt() 不和 {{JSxRef("Operators/new", "new")}} 一起使用。

    @@ -47,8 +47,8 @@ const hugeBin = BigInt("0b11111111111111111111111111111111111111111111111111111"

    BigInt 跟 {{JSxRef("Number")}} 很像,但在某些部分有些許不同 — 它不可以被用在內建的 {{JSxRef("Math")}} 物件方法中、而且不可以跟 Number 的實體混用運算子。

    -
    -

    {{JSxRef("Number")}} 和 BigInt 不能混和計算 — 他們必須被轉換到同一個型態。

    +
    +

    警告: {{JSxRef("Number")}} 和 BigInt 不能混和計算 — 他們必須被轉換到同一個型態。

    然而,在相互轉換時要注意, BigInt 在被轉換成 Number 時可能會遺失部分精度的資訊。

    @@ -97,8 +97,8 @@ bigN * -1n

    / 運算子也同樣的能夠運行。然而,因為型態是 BigInt 而不是 BigDecimal ,除法運算會無條件捨去小數。也就是說,回傳值不會包含小數部分。

    -
    -

    回傳值帶小數的運算在使用BigInt  時小數部分會被捨去。

    +
    +

    警告:回傳值帶小數的運算在使用BigInt 時小數部分會被捨去。

    const expected = 4n / 2n;
    @@ -251,26 +251,11 @@ nthPrime(20n)
     
     

    規範

    - - - - - - - - - - - -
    規範狀態
    BigIntStage 3
    +{{Specifications}}

    瀏覽器相容性

    -
    - - -

    {{Compat("javascript.builtins.BigInt")}}

    -
    +{{Compat}}

    另見

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/boolean/index.html b/files/zh-tw/web/javascript/reference/global_objects/boolean/index.html index 0e817070dc..d35d07470b 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/boolean/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/boolean/index.html @@ -104,91 +104,13 @@ var bObjProto = new Boolean({});

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    規範狀態註記
    {{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
    {{SpecName('ES5.1', '#sec-15.6', 'Boolean')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-boolean-objects', 'Boolean')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-boolean-objects', 'Boolean')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    {{CompatibilityTable}}
    -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatIE("6.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/dataview/index.html b/files/zh-tw/web/javascript/reference/global_objects/dataview/index.html index 8d4406dd9e..f7ef3094ff 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/dataview/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/dataview/index.html @@ -80,82 +80,11 @@ dv.getInt16(1); //42

    規範

    - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('Typed Array')}}{{Spec2('Typed Array')}}Superseded by ECMAScript 6
    {{SpecName('ES6', '#sec-dataview-constructor', 'DataView')}}{{Spec2('ES6')}}Initial definition in an ECMA standard
    {{SpecName('ESDraft', '#sec-dataview-constructor', 'DataView')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support9.0{{CompatGeckoDesktop("15.0")}}1012.15.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support4.0{{CompatVersionUnknown}}{{CompatGeckoMobile("15")}}{{CompatUnknown}}12.04.2
    -
    +{{Compat}}

    Firefox-specific notes

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/date/getday/index.html b/files/zh-tw/web/javascript/reference/global_objects/date/getday/index.html index dd5ebc36d4..80ab81fa2d 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/date/getday/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/date/getday/index.html @@ -29,8 +29,8 @@ var weekday = Xmas95.getDay(); console.log(weekday); // 1
    -
    -

    Note: 如果需要,可以使用{{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}}加上options參數來獲取星期幾全名。使使用此方法能輕鬆做出各種國際語言:

    +
    +

    備註:如果需要,可以使用{{jsxref("DateTimeFormat", "Intl.DateTimeFormat")}}加上options參數來獲取星期幾全名。使使用此方法能輕鬆做出各種國際語言:

    var options = { weekday: 'long'};
     console.log(new Intl.DateTimeFormat('en-US', options).format(Xmas95));
    diff --git a/files/zh-tw/web/javascript/reference/global_objects/date/index.html b/files/zh-tw/web/javascript/reference/global_objects/date/index.html
    index 1b1873dd22..9e7cab6fe9 100644
    --- a/files/zh-tw/web/javascript/reference/global_objects/date/index.html
    +++ b/files/zh-tw/web/javascript/reference/global_objects/date/index.html
    @@ -18,18 +18,18 @@ new Date(dateString);
     new Date(year, month[, day[, hour[, minutes[, seconds[, milliseconds]]]]]);
     
    -
    -

    附註: JavaScript Date 物件只能由以 Date 作為建構子來產生,如果把 Date 作為一般的函數來呼叫(省略掉 {{jsxref("Operators/new", "new")}} 運算子)將會得到一個字串而非 Date 物件;與其它 JavaScript 物件不同,它並沒有物件實體語法(例如:以中刮號 [ ] 表示陣列的宣告方式)。

    +
    +

    備註:JavaScript Date 物件只能由以 Date 作為建構子來產生,如果把 Date 作為一般的函數來呼叫(省略掉 {{jsxref("Operators/new", "new")}} 運算子)將會得到一個字串而非 Date 物件;與其它 JavaScript 物件不同,它並沒有物件實體語法(例如:以中刮號 [ ] 表示陣列的宣告方式)。

    參數

    -
    -

    附註:當傳入超過一個參數到 Date 建構子,若參數值超過它的合理範圍(例如:傳數值 13 到月份,或傳數值 70 給分鐘),相鄰的參數值將會被調整。例如: new Date(2013, 13, 1) 將等同於 new Date(2014, 1, 1) 都會建立代表 2014-02-01 的物件(注意月份值由 0 開始)。同樣的, new Date(2013, 2, 1, 0, 70)new Date(2013, 2, 1, 1, 10) 一樣會建立代表 2013-03-01T01:10:00 的 Date 物件。

    +
    +

    備註:當傳入超過一個參數到 Date 建構子,若參數值超過它的合理範圍(例如:傳數值 13 到月份,或傳數值 70 給分鐘),相鄰的參數值將會被調整。例如: new Date(2013, 13, 1) 將等同於 new Date(2014, 1, 1) 都會建立代表 2014-02-01 的物件(注意月份值由 0 開始)。同樣的, new Date(2013, 2, 1, 0, 70)new Date(2013, 2, 1, 1, 10) 一樣會建立代表 2013-03-01T01:10:00 的 Date 物件。

    -
    -

    附註:當傳入超過一個參數到 Date 建構子,所指定的參數值會視為本地時間。如果希望指定的值為世界標準時間(UTC),則應使用 new Date({{jsxref("Date.UTC()", "Date.UTC(...)")}}) 語法,傳入一樣格式的參數。

    +
    +

    備註:當傳入超過一個參數到 Date 建構子,所指定的參數值會視為本地時間。如果希望指定的值為世界標準時間(UTC),則應使用 new Date({{jsxref("Date.UTC()", "Date.UTC(...)")}}) 語法,傳入一樣格式的參數。

    @@ -37,8 +37,8 @@ new Date(year, month[, day[, hour[,
    自世界標準時間(UTC) 1970 年 1 月 1 日 00:00:00 開始的毫秒整數(Integer)值(Unix 紀元;但要注意到大多 Unix 時間戳記是以秒而非毫秒為單位)。
    dateString
    表示時間日期的字串。這個字串應該要能被 {{jsxref("Date.parse()")}} 方法解析(符合 IETF-compliant RFC 2822 timestampsversion of ISO8601 格式要求). -
    -

    附註: 由於各家瀏覽器有所不同且具有差異性,因此非常不鼓勵使用 Date 建構子(或 Date.parse 方法,它們是同等的)來解析時間日期字串。

    +
    +

    備註:由於各家瀏覽器有所不同且具有差異性,因此非常不鼓勵使用 Date 建構子(或 Date.parse 方法,它們是同等的)來解析時間日期字串。

    year
    @@ -84,8 +84,8 @@ new Date(year, month[, day[, hour[,
    回傳對應於當下時間的數值 - 1970/01/01 00:00:00 (UTC) 到當下的毫秒數。
    {{jsxref("Date.parse()")}}
    解析字串所表示的時間,回傳由 1970/01/01 00:00:00 (UTC) 到該時間的毫秒數值。 -
    -

    附註:由於瀏覽器之間的不同與差異,強烈不建議使用 Date.parse

    +
    +

    備註:由於瀏覽器之間的不同與差異,強烈不建議使用 Date.parse

    {{jsxref("Date.UTC()")}}
    @@ -106,8 +106,8 @@ new Date(year, month[, day[, hour[,

    接下來的幾個範例,展示幾種建立 Date 物件的方式:

    -
    -

    附註: 由於瀏覽器之間的不同與差異,強烈不建議使用解析字串的方式建立 Date 物件。

    +
    +

    備註:由於瀏覽器之間的不同與差異,強烈不建議使用解析字串的方式建立 Date 物件。

    var today = new Date();
    @@ -166,97 +166,17 @@ function printElapsedTime(fTest) {
     yourFunctionReturn = printElapsedTime(yourFunction);
     
    -
    -

    附註:在瀏覽器支援 {{domxref("window.performance", "Web Performance API", "", 1)}} 高精度特性下, {{domxref("Performance.now()")}} 可以提供比 {{jsxref("Date.now()")}} 更可靠、精確的執行時間測試結果。

    +
    +

    備註:在瀏覽器支援 {{domxref("window.performance", "Web Performance API", "", 1)}} 高精度特性下, {{domxref("Performance.now()")}} 可以提供比 {{jsxref("Date.now()")}} 更可靠、精確的執行時間測試結果。

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    規範狀態
    {{SpecName('ESDraft', '#sec-date-objects', 'Date')}}{{Spec2('ESDraft')}} 
    {{SpecName('ES6', '#sec-date-objects', 'Date')}}{{Spec2('ES6')}} 
    {{SpecName('ES5.1', '#sec-15.9', 'Date')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES1')}}{{Spec2('ES1')}}初步定義。實作在 JavaScript 1.1。
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    平台ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    -

    基本支援

    -
    {{CompatVersionUnknown}} [1]{{CompatVersionUnknown}} [1]{{CompatVersionUnknown}} [2]{{CompatVersionUnknown}} [1]{{CompatVersionUnknown}} [1]
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    平台AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    -

    基本支援

    -
    {{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    [1] 一些瀏覽器在解析日期時間會發生問題: 3/14/2012 blog from danvk Comparing FF/IE/Chrome on Parsing Date Strings

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/date/now/index.html b/files/zh-tw/web/javascript/reference/global_objects/date/now/index.html index ca67a2e534..a6ea13ec86 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/date/now/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/date/now/index.html @@ -38,82 +38,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/now

    規範

    - - - - - - - - - - - - - - - - - - - - - - - -
    規範狀態
    {{SpecName('ES5.1', '#sec-15.9.4.4', 'Date.now')}}{{Spec2('ES5.1')}}初始定義,實作在 JavaScript 1.5 。
    {{SpecName('ES6', '#sec-date.now', 'Date.now')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-date.now', 'Date.now')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    平台ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支援{{CompatChrome("5")}}{{CompatGeckoDesktop("1.9")}}{{CompatIE("9")}}{{CompatOpera("10.50")}}{{CompatSafari("4")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    平台AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基本支援{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    相關資源

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/date/utc/index.html b/files/zh-tw/web/javascript/reference/global_objects/date/utc/index.html index 50ab7590ea..9d9a95d526 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/date/utc/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/date/utc/index.html @@ -67,88 +67,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/UTC

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    規範狀態
    {{SpecName('ESDraft', '#sec-date.utc', 'Date.UTC')}}{{Spec2('ESDraft')}} 
    {{SpecName('ES6', '#sec-date.utc', 'Date.UTC')}}{{Spec2('ES6')}} 
    {{SpecName('ES5.1', '#sec-15.9.4.3', 'Date.UTC')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES1')}}{{Spec2('ES1')}}初始定義。
    - 實作在 JavaScript 1.0.
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    平台ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本支援{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    平台AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基本支援{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    相關資源

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/error/columnnumber/index.html b/files/zh-tw/web/javascript/reference/global_objects/error/columnnumber/index.html index ca1dc77233..55e052ed77 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/error/columnnumber/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/error/columnnumber/index.html @@ -22,55 +22,7 @@ console.log(e.columnNumber) // 0

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatNo}}{{CompatNo}}{{CompatVersionUnknown}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    See also

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/error/index.html b/files/zh-tw/web/javascript/reference/global_objects/error/index.html index 51e58faf45..67f675c25a 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/error/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/error/index.html @@ -111,8 +111,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Error

    You might want to define your own error types deriving from Error to be able to throw new MyError() and use instanceof MyError to check the kind of error in the exception handler. The common way to do this is demonstrated below.

    -
    -

    Note that the thrown MyError will report incorrect lineNumber and fileName at least in Firefox.

    +
    +

    Warning: Note that the thrown MyError will report incorrect lineNumber and fileName at least in Firefox.

    See also the "What's a good way to extend Error in JavaScript?" discussion on Stackoverflow.

    @@ -142,87 +142,11 @@ try {

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.1.
    {{SpecName('ES5.1', '#sec-15.11', 'Error')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-error-objects', 'Error')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-error-objects', 'Error')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/function/apply/index.html b/files/zh-tw/web/javascript/reference/global_objects/function/apply/index.html index 9d5aba8312..03e58de21b 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/function/apply/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/function/apply/index.html @@ -7,8 +7,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply

    apply() 方法會呼叫一個以 this 的代表值和一個陣列形式的值組(或是一個 array-like object )為參數的函式。

    -
    -

    注意:這個函式的語法和{{jsxref("Function.call", "call()")}} 幾乎一樣,最大的不同是 call() 接受一連串的參數,而 apply() 接受一組陣列形式的參數

    +
    +

    備註:這個函式的語法和{{jsxref("Function.call", "call()")}} 幾乎一樣,最大的不同是 call() 接受一連串的參數,而 apply() 接受一組陣列形式的參數

    語法

    @@ -38,8 +38,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply

    從 ECMAScript 5th 版本後,也可以使用陣列形式的物件,在實踐上這代表他會擁有 length 以及整數範圍  (0...length-1) 的屬性。舉例來說,你可以使用 {{domxref("NodeList")}}  或是一個像這樣的自定義屬性: { 'length': 2, '0': 'eat', '1': 'bananas' }。

    -
    -

    一般瀏覽器,包括 Chrome 14 及 Internet Explorer 9,仍不支援陣列形式的物件,所以會對此丟出一個錯誤。

    +
    +

    備註:一般瀏覽器,包括 Chrome 14 及 Internet Explorer 9,仍不支援陣列形式的物件,所以會對此丟出一個錯誤。

    範例

    @@ -55,8 +55,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply };
    -
    -

    注意:如上範例的 Object.create() 方法是屬於比較新的寫法。如需使用閉包的替代方法,請參考以下的範例:

    +
    +

    備註:如上範例的 Object.create() 方法是屬於比較新的寫法。如需使用閉包的替代方法,請參考以下的範例:

    Function.prototype.construct = function(aArgs) {
       var fConstructor = this, fNewConstr = function() {
    @@ -83,8 +83,8 @@ console.log(myInstance instanceof MyConstructor); // logs 'true'
     console.log(myInstance.constructor);              // logs 'MyConstructor'
     
    -
    -

    注意:This non-native Function.construct method will not work with some native constructors (like {{jsxref("Date")}}, for example). In these cases you have to use the {{jsxref("Function.prototype.bind")}} method (for example, imagine having an array like the following, to be used with {{jsxref("Global_Objects/Date", "Date")}} constructor: [2012, 11, 4]; in this case you have to write something like: new (Function.prototype.bind.apply(Date, [null].concat([2012, 11, 4])))() — anyhow this is not the best way to do things and probably should not be used in any production environment).

    +
    +

    備註:This non-native Function.construct method will not work with some native constructors (like {{jsxref("Date")}}, for example). In these cases you have to use the {{jsxref("Function.prototype.bind")}} method (for example, imagine having an array like the following, to be used with {{jsxref("Global_Objects/Date", "Date")}} constructor: [2012, 11, 4]; in this case you have to write something like: new (Function.prototype.bind.apply(Date, [null].concat([2012, 11, 4])))() — anyhow this is not the best way to do things and probably should not be used in any production environment).

    使用 apply 於內建的函數

    @@ -150,104 +150,11 @@ someobject.foo = function() {

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES3')}}{{Spec2('ES3')}}Initial definition. Implemented in JavaScript 1.3.
    {{SpecName('ES5.1', '#sec-15.3.4.3', 'Function.prototype.apply')}}{{Spec2('ES5.1')}}
    {{SpecName('ES6', '#sec-function.prototype.apply', 'Function.prototype.apply')}}{{Spec2('ES6')}}
    {{SpecName('ESDraft', '#sec-function.prototype.apply', 'Function.prototype.apply')}}{{Spec2('ESDraft')}}
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    ES 5.1 generic array-like object as {{jsxref("Functions/arguments", "arguments")}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("2.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    ES 5.1 generic array-like object as {{jsxref("Functions/arguments", "arguments")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("2.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/function/bind/index.html b/files/zh-tw/web/javascript/reference/global_objects/function/bind/index.html index 006db2aa4c..12ce075840 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/function/bind/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/function/bind/index.html @@ -108,7 +108,7 @@ flower.bloom();

    Bound functions used as constructors

    -
    +

    Warning: This section demonstrates JavaScript capabilities and documents some edge cases of the bind() method. The methods shown below are not the best way to do things and probably should not be used in any production environment.

    @@ -231,86 +231,11 @@ slice(arguments);

    規範

    - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES5.1', '#sec-15.3.4.5', 'Function.prototype.bind')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.8.5.
    {{SpecName('ES2015', '#sec-function.prototype.bind', 'Function.prototype.bind')}}{{Spec2('ES2015')}} 
    {{SpecName('ESDraft', '#sec-function.prototype.bind', 'Function.prototype.bind')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("7")}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("2")}}{{CompatIE("9")}}{{CompatOpera("11.60")}}{{CompatSafari("5.1")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatAndroid("4.0")}}{{CompatChrome("1")}}{{CompatVersionUnknown}}{{CompatGeckoMobile("2")}}{{CompatUnknown}}{{CompatOperaMobile("11.5")}}{{CompatSafari("6.0")}}
    -
    +{{Compat}}

    相關連結

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/function/call/index.html b/files/zh-tw/web/javascript/reference/global_objects/function/call/index.html index 1d1d2017ee..64a42d065a 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/function/call/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/function/call/index.html @@ -9,12 +9,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/call

    使用給定的this參數以及分別給定的參數來呼叫某個函數

    -
    附註: 此函數的所有語法大致上與apply()相同,他們基本上不同處只有 call() 接受一連串的參數,而 apply() 單一的array作為參數
    +
    +

    備註: 此函數的所有語法大致上與apply()相同,他們基本上不同處只有 call() 接受一連串的參數,而 apply() 單一的array作為參數

    +
    - + @@ -98,6 +100,14 @@ for (var i = 0; i < animals.length; i++) { } +

    規範

    + +{{Specifications}} + +

    瀏覽器相容性

    + +{{Compat}} +

    參見

      diff --git a/files/zh-tw/web/javascript/reference/global_objects/function/index.html b/files/zh-tw/web/javascript/reference/global_objects/function/index.html index c7321e3bd8..72c75d7615 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/function/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/function/index.html @@ -96,87 +96,11 @@ console.log(f2()); // 20

      規範

      -
    Function 物件的方法Function 物件的方法
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
    {{SpecName('ES5.1', '#sec-15.3', 'Function')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-function-objects', 'Function')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-function-objects', 'Function')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/function/length/index.html b/files/zh-tw/web/javascript/reference/global_objects/function/length/index.html index f1498d4e5d..6e83cb3b2c 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/function/length/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/function/length/index.html @@ -38,104 +38,11 @@ console.log((function(a, b = 1, c) {}).length); /* 1 */

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    規範狀態註釋
    {{SpecName('ES1')}}{{Spec2('ES1')}}最初的定義,在 JavaScript 1.1 中實作。
    {{SpecName('ES5.1', '#sec-15.3.5.1', 'Function.length')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-function-instances-length', 'Function.length')}}{{Spec2('ES6')}}此 property 的 configurable attribute 現在為 true.
    {{SpecName('ESDraft', '#sec-function-instances-length', 'Function.length')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    特點ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    Configurable: true{{CompatUnknown}}{{CompatGeckoDesktop(37)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    Configurable: true{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile(37)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    可參閱

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/json/parse/index.html b/files/zh-tw/web/javascript/reference/global_objects/json/parse/index.html index 663d5fb6ce..c5623e7a89 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/json/parse/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/json/parse/index.html @@ -77,82 +77,11 @@ JSON.parse('{"foo" : 1, }');

    規範

    - - - - - - - - - - - - - - - - - - - - - - - -
    規範狀態註解
    {{SpecName('ES5.1', '#sec-15.12.2', 'JSON.parse')}}{{Spec2('ES5.1')}}初始定義。從 JavaScript 1.7 導入。
    {{SpecName('ES6', '#sec-json.parse', 'JSON.parse')}}{{Spec2('ES6')}}
    {{SpecName('ESDraft', '#sec-json.parse', 'JSON.parse')}}{{Spec2('ESDraft')}}
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    特徵ChromeFirefox (Gecko)Internet ExplorerOperaSafari
    基本功能{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.9.1")}}{{CompatIE("8.0")}}{{CompatOpera("10.5")}}{{CompatSafari("4.0")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    特徵AndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    基本功能{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    Gecko相關

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/json/stringify/index.html b/files/zh-tw/web/javascript/reference/global_objects/json/stringify/index.html index 98f01ef784..bc254ca8b5 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/json/stringify/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/json/stringify/index.html @@ -76,7 +76,7 @@ JSON.stringify( Object.create(null, { x: { value: 'x', enumerable: false }, y: {
    -

    The replacer parameter

    +

    The replacer parameter

    The replacer parameter can be either a function or an array. As a function, it takes two parameters, the key and the value being stringified. The object in which the key was found is provided as the replacer's this parameter. Initially it gets called with an empty key representing the object being stringified, and it then gets called for each property on the object or array being stringified. It should return the value that should be added to the JSON string, as follows:

    @@ -88,7 +88,7 @@ JSON.stringify( Object.create(null, { x: { value: 'x', enumerable: false }, y: {
  • If you return undefined, the property is not included (i.e., filtered out) in the output JSON string.
  • -
    Note: You cannot use the replacer function to remove values from an array. If you return undefined or a function then null is used instead.
    +

    Note: You cannot use the replacer function to remove values from an array. If you return undefined or a function then null is used instead.

    Example with a function

    @@ -113,7 +113,7 @@ JSON.stringify(foo, replacer); // '{"week":45,"month":7}', only keep "week" and "month" properties
    -

    The space argument

    +

    The space argument

    The space argument may be used to control spacing in the final string. If it is a number, successive levels in the stringification will each be indented by this many space characters (up to 10). If it is a string, successive levels will be indented by this string (or the first ten characters of it).

    @@ -209,8 +209,8 @@ alert(jsFriendlyJSONStringify(s)); // {"a":"\u2028","b":"\u2029"}

    In a case where you want to store an object created by your user and allowing it to be restored even after the browser has been closed, the following example is a model for the applicability of JSON.stringify():

    -
    -

    Functions are not a valid JSON data type so they will not work. However, they can be displayed if first converted to a string (e.g. in the replacer), via the function's toString method. Also, some objects like {{jsxref("Date")}} will be a string after {{jsxref("JSON.parse()")}}.

    +
    +

    Warning: Functions are not a valid JSON data type so they will not work. However, they can be displayed if first converted to a string (e.g. in the replacer), via the function's toString method. Also, some objects like {{jsxref("Date")}} will be a string after {{jsxref("JSON.parse()")}}.

    // Creating an example of JSON
    @@ -238,40 +238,13 @@ var restoredSession = JSON.parse(localStorage.getItem('session'));
     console.log(restoredSession);
     
    -

    Specifications

    - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES5.1', '#sec-15.12.3', 'JSON.stringify')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.7.
    {{SpecName('ES6', '#sec-json.stringify', 'JSON.stringify')}}{{Spec2('ES6')}}
    {{SpecName('ESDraft', '#sec-json.stringify', 'JSON.stringify')}}{{Spec2('ESDraft')}}
    - -

    Browser compatibility

    - -
    - - -

    {{Compat("javascript.builtins.JSON.stringify")}}

    -
    +

    規範

    + +{{Specifications}} + +

    瀏覽器相容性

    + +{{Compat}}

    See also

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/math/index.html b/files/zh-tw/web/javascript/reference/global_objects/math/index.html index 2b09b4de23..b200a53959 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/math/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/math/index.html @@ -40,12 +40,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math

    方法

    -
    -

    注意三角函數 (sin(), cos(), tan(), asin(), acos(), atan(), atan2()) 的參數或回傳值的角度皆以弧度為單位。把角度乘上 (Math.PI / 180) 會得到弧度單位,將弧度除以該數則會轉換回一般所用的角度單位。

    +
    +

    備註:三角函數 (sin(), cos(), tan(), asin(), acos(), atan(), atan2()) 的參數或回傳值的角度皆以弧度為單位。把角度乘上 (Math.PI / 180) 會得到弧度單位,將弧度除以該數則會轉換回一般所用的角度單位。

    -
    -

    注意許多數學方法的精度是取決於實作方式的。這意味著不同的瀏覽器可能會得到不同的結果,甚至同一個 JS引擎在不同的作業系統或架構上所得到的結果都有可能相異。

    +
    +

    備註:許多數學方法的精度是取決於實作方式的。這意味著不同的瀏覽器可能會得到不同的結果,甚至同一個 JS引擎在不同的作業系統或架構上所得到的結果都有可能相異。

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/math/random/index.html b/files/zh-tw/web/javascript/reference/global_objects/math/random/index.html index 6731d1c2b4..8087d30bfd 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/math/random/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/math/random/index.html @@ -10,8 +10,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random

    函數 Math.random() 會回傳一個偽隨機小數 (pseudo-random) 介於0到1之間(包含 0,不包含1) ,大致符合數學與統計上的均勻分佈 (uniform distribution) ,您可以選定想要的數字區間,它會透過演算法被產生並且不允許使用者自行跳選或重設成特定數字。{{EmbedInteractiveExample("pages/js/math-random.html")}}

    -
    -

    Math.random() 所產生的偽隨機小數不符合加密學安全性要求。請勿使用於任何加密、資安相關領域。

    +
    +

    備註:Math.random() 所產生的偽隨機小數不符合加密學安全性要求。請勿使用於任何加密、資安相關領域。

    如有加密需求建議參考Web Crypto APIwindow.crypto.getRandomValues()

    @@ -55,8 +55,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random }
    -
    -

    It might be tempting to use Math.round() to accomplish that, but doing so would cause your random numbers to follow a non-uniform distribution, which may not be acceptable for your needs.

    +
    +

    Note: might be tempting to use Math.round() to accomplish that, but doing so would cause your random numbers to follow a non-uniform distribution, which may not be acceptable for your needs.

    Getting a random integer between two values, inclusive

    @@ -69,24 +69,15 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Math/random return Math.floor(Math.random() * (max - min + 1) + min); //The maximum is inclusive and the minimum is inclusive }
    -

    Specifications

    +

    規範

    - - - - - - - - - -
    Specification
    {{SpecName('ESDraft', '#sec-math.random', 'Math.random')}}
    +{{Specifications}}

    瀏覽器相容性

    -

    {{Compat("javascript.builtins.Math.random")}}

    +{{Compat}} -

    其他參考資料

    +

    其他參考資料

    • window.crypto.getRandomValues()
    • diff --git a/files/zh-tw/web/javascript/reference/global_objects/math/round/index.html b/files/zh-tw/web/javascript/reference/global_objects/math/round/index.html index efde660a66..8b37f8b851 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/math/round/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/math/round/index.html @@ -126,80 +126,11 @@ Math.ceil10(-59, 1); // -50

      規範

      - - - - - - - - - - - - - - - - - - - - - - - -
      規範狀態
      {{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
      {{SpecName('ES5.1', '#sec-15.8.2.15', 'Math.round')}}{{Spec2('ES5.1')}} 
      {{SpecName('ES6', '#sec-math.round', 'Math.round')}}{{Spec2('ES6')}} 
      +{{Specifications}}

      瀏覽器相容性

      -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidFirefox Mobile (Gecko)IE PhoneOpera MobileSafari Mobile
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      +{{Compat}}

      參見

      diff --git a/files/zh-tw/web/javascript/reference/global_objects/null/index.html b/files/zh-tw/web/javascript/reference/global_objects/null/index.html index a32debbd16..2e270445a6 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/null/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/null/index.html @@ -34,87 +34,11 @@ null == undefined // true

      規範

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      SpecificationStatusComment
      {{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition.
      {{SpecName('ES5.1', '#sec-4.3.11', 'null value')}}{{Spec2('ES5.1')}} 
      {{SpecName('ES6', '#sec-null-value', 'null value')}}{{Spec2('ES6')}} 
      {{SpecName('ESDraft', '#sec-null-value', 'null value')}}{{Spec2('ESDraft')}} 
      +{{Specifications}}

      瀏覽器相容性

      -

      {{CompatibilityTable}}

      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      +{{Compat}}

      參見

      diff --git a/files/zh-tw/web/javascript/reference/global_objects/number/index.html b/files/zh-tw/web/javascript/reference/global_objects/number/index.html index cda3475d0b..45500f4178 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/number/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/number/index.html @@ -67,8 +67,6 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Number
      判斷傳入的值是不是一個整數。
      {{jsxref("Number.isSafeInteger()")}}
      判斷傳入的值是不是在 IEEE-754 雙精度範圍間 (即介於 -(2^53 - 1) 和 2^53 - 1之前)。
      -
      {{jsxref("Number.toInteger()")}} {{obsolete_inline}}
      -
      被用來評估傳入的值且將其轉換成整數 (或 {{jsxref("Global_Objects/Infinity", "Infinity")}}) 但已被移除。
      {{jsxref("Number.parseFloat()")}}
      這個方法和全域物件的 {{jsxref("parseFloat", "parseFloat()")}} 相同。
      {{jsxref("Number.parseInt()")}}
      @@ -129,87 +127,11 @@ Number("100a") // NaN

      規範

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      規範狀態註記
      {{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.1.
      {{SpecName('ES5.1', '#sec-15.7', 'Number')}}{{Spec2('ES5.1')}} 
      {{SpecName('ES6', '#sec-number-objects', 'Number')}}{{Spec2('ES6')}}New methods and properties added: {{jsxref("Number.EPSILON", "EPSILON")}}, {{jsxref("Number.isFinite", "isFinite")}}, {{jsxref("Number.isInteger", "isInteger")}}, {{jsxref("Number.isNaN", "isNaN")}}, {{jsxref("Number.parseFloat", "parseFloat")}}, {{jsxref("Number.parseInt", "parseInt")}}
      {{SpecName('ESDraft', '#sec-number-objects', 'Number')}}{{Spec2('ESDraft')}} 
      - -

      瀏覽器相容

      - -
      {{CompatibilityTable}}
      - -
      - - - - - - - - - - - - - - - - - - - -
      FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      - -
      - - - - - - - - - - - - - - - - - - - - - -
      FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
      Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
      -
      +{{Specifications}} + +

      瀏覽器相容性

      + +{{Compat}}

      參見

      diff --git a/files/zh-tw/web/javascript/reference/global_objects/number/toexponential/index.html b/files/zh-tw/web/javascript/reference/global_objects/number/toexponential/index.html index 9c40c2fe5b..884ed6d97c 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/number/toexponential/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/number/toexponential/index.html @@ -71,89 +71,13 @@ console.log(77.1234.toExponential()); // logs 7.71234e+1 console.log(77 .toExponential()); // logs 7.7e+1
    -

    Specifications

    +

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES3')}}{{Spec2('ES3')}}Initial definition. Implemented in JavaScript 1.5.
    {{SpecName('ES5.1', '#sec-15.7.4.6', 'Number.prototype.toExponential')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-number.prototype.toexponential', 'Number.prototype.toExponential')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-number.prototype.toexponential', 'Number.prototype.toExponential')}}{{Spec2('ESDraft')}} 
    - -

    瀏覽器支援度

    +{{Specifications}} -
    {{CompatibilityTable}}
    +

    瀏覽器相容性

    -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    延伸閱讀

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/object/create/index.html b/files/zh-tw/web/javascript/reference/global_objects/object/create/index.html index f8e71aeae1..b58f9173cd 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/object/create/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/object/create/index.html @@ -171,82 +171,11 @@ o2 = Object.create({}, {

    規範

    - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES5.1', '#sec-15.2.3.5', 'Object.create')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.8.5.
    {{SpecName('ES6', '#sec-object.create', 'Object.create')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-object.create', 'Object.create')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("5")}}{{CompatGeckoDesktop("2")}}{{CompatIE("9")}}{{CompatOpera("11.60")}}{{CompatSafari("5")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("2")}}{{CompatVersionUnknown}}{{CompatOperaMobile("11.5")}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參閱

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/object/defineproperties/index.html b/files/zh-tw/web/javascript/reference/global_objects/object/defineproperties/index.html index 7739ab4bdd..1ea2f29f71 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/object/defineproperties/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/object/defineproperties/index.html @@ -69,7 +69,7 @@ Object.defineProperties(obj, {

    Assuming a pristine execution environment with all names and properties referring to their initial values, Object.defineProperties is almost completely equivalent (note the comment in isCallable) to the following reimplementation in JavaScript:

    -
    function defineProperties(obj, properties) {
    +
    function defineProperties(obj, properties) {
       function convertToDescriptor(desc) {
         function hasProperty(obj, prop) {
           return Object.prototype.hasOwnProperty.call(obj, prop);
    @@ -131,82 +131,13 @@ Object.defineProperties(obj, {
     }
     
    -

    規格

    - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatus註記
    {{SpecName('ES5.1', '#sec-15.2.3.7', 'Object.defineProperties')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.8.5
    {{SpecName('ES6', '#sec-object.defineproperties', 'Object.defineProperties')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-object.defineproperties', 'Object.defineProperties')}}{{Spec2('ESDraft')}} 
    +

    規範

    + +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureFirefox (Gecko)ChromeInternet ExplorerOperaSafari
    Basic support{{CompatGeckoDesktop("2")}}{{CompatChrome("5")}}{{CompatIE("9")}}{{CompatOpera("11.60")}}{{CompatSafari("5")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureFirefox Mobile (Gecko)AndroidIE MobileOpera MobileSafari Mobile
    Basic support{{CompatGeckoMobile("2")}}{{CompatVersionUnknown}}{{CompatUnknown}}{{CompatOperaMobile("11.5")}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參閱

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/object/defineproperty/index.html b/files/zh-tw/web/javascript/reference/global_objects/object/defineproperty/index.html index f9f6c44d39..7413ff384c 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/object/defineproperty/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/object/defineproperty/index.html @@ -7,8 +7,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperty

    靜態方法 Object.defineProperty() 會直接對一個物件定義、或是修改現有的屬性。執行後會回傳定義完的物件。

    -
    -

    注:這個方法會直接針對 {{jsxref("Object")}} 呼叫建構子(constructor),而不是 Object 型別的實例。

    +
    +

    備註:這個方法會直接針對 {{jsxref("Object")}} 呼叫建構子(constructor),而不是 Object 型別的實例。

    {{EmbedInteractiveExample("pages/js/object-defineproperty.html")}}
    diff --git a/files/zh-tw/web/javascript/reference/global_objects/object/getprototypeof/index.html b/files/zh-tw/web/javascript/reference/global_objects/object/getprototypeof/index.html index b063094f52..8f0ff15f9f 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/object/getprototypeof/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/object/getprototypeof/index.html @@ -41,77 +41,11 @@ Object.getPrototypeOf("foo");

    規範

    - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES5.1', '#sec-15.2.3.2', 'Object.getPrototypeOf')}}{{Spec2('ES5.1')}}Initial definition.
    {{SpecName('ES6', '#sec-object.getprototypeof', 'Object.getProtoypeOf')}}{{Spec2('ES6')}} 
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("5")}}{{CompatGeckoDesktop("1.9.1")}}{{CompatIE("9")}}{{CompatOpera("12.10")}}{{CompatSafari("5")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    Opera 註

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/object/hasownproperty/index.html b/files/zh-tw/web/javascript/reference/global_objects/object/hasownproperty/index.html index 58fe485c22..41bd582c4e 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/object/hasownproperty/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/object/hasownproperty/index.html @@ -96,82 +96,11 @@ Object.prototype.hasOwnProperty.call(foo, 'bar'); // true

    規範

    - - - - - - - - - - - - - - - - - - - - - - - -
    規範狀態
    {{SpecName('ES3')}}{{Spec2('ES3')}}Initial definition. Implemented in JavaScript 1.5.
    {{SpecName('ES5.1', '#sec-15.2.4.5', 'Object.prototype.hasOwnProperty')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-object.prototype.hasownproperty', 'Object.prototype.hasOwnProperty')}}{{Spec2('ES6')}} 
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/object/index.html b/files/zh-tw/web/javascript/reference/global_objects/object/index.html index 40468bd608..89e99e6359 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/object/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/object/index.html @@ -133,87 +133,11 @@ var o = new Object(Boolean());

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0.
    {{SpecName('ES5.1', '#sec-15.2', 'Object')}}{{Spec2('ES5.1')}}
    {{SpecName('ES6', '#sec-object-objects', 'Object')}}{{Spec2('ES6')}}Added Object.assign, Object.getOwnPropertySymbols, Object.setPrototypeOf, Object.is
    {{SpecName('ESDraft', '#sec-object-objects', 'Object')}}{{Spec2('ESDraft')}}Added Object.entries, Object.values and Object.getOwnPropertyDescriptors.
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/object/keys/index.html b/files/zh-tw/web/javascript/reference/global_objects/object/keys/index.html index 5bf8e8a559..3be978f7f8 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/object/keys/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/object/keys/index.html @@ -119,82 +119,11 @@ if (!Object.keys) {

    規範

    - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES5.1', '#sec-15.2.3.14', 'Object.keys')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.8.5.
    {{SpecName('ES2015', '#sec-object.keys', 'Object.keys')}}{{Spec2('ES2015')}} 
    {{SpecName('ESDraft', '#sec-object.keys', 'Object.keys')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("5")}}{{CompatGeckoDesktop("2.0")}}{{CompatIE("9")}}{{CompatOpera("12")}}{{CompatSafari("5")}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/object/preventextensions/index.html b/files/zh-tw/web/javascript/reference/global_objects/object/preventextensions/index.html index da1dc83526..2a06e61d0c 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/object/preventextensions/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/object/preventextensions/index.html @@ -73,99 +73,11 @@ Object.preventExtensions(1);

    規範

    - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES5.1', '#sec-15.2.3.10', 'Object.preventExtensions')}}{{Spec2('ES5.1')}}Initial definition. Implemented in JavaScript 1.8.5.
    {{SpecName('ES6', '#sec-object.preventextensions', 'Object.preventExtensions')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-object.preventextensions', 'Object.preventExtensions')}}{{Spec2('ESDraft')}} 
    - -

    瀏覽器相容度

    - -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome("6")}}{{CompatGeckoDesktop("2.0")}}{{CompatIE("9")}}{{CompatOpera("12")}}{{CompatSafari("5.1")}}
    ES6 behavior for non-object argument{{CompatChrome("44")}}{{CompatGeckoDesktop("35.0")}}{{CompatIE("11")}}{{CompatOpera("31")}}{{CompatUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    ES6 behavior for non-object argument{{CompatUnknown}}{{CompatUnknown}}{{CompatGeckoMobile("35.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
    -
    +{{Specifications}} + +

    瀏覽器相容性

    + +{{Compat}}

    閱讀更多

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/object/proto/index.html b/files/zh-tw/web/javascript/reference/global_objects/object/proto/index.html index 5ba5c8f615..ebb05d1e1d 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/object/proto/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/object/proto/index.html @@ -3,11 +3,11 @@ title: Object.prototype.__proto__ slug: Web/JavaScript/Reference/Global_Objects/Object/proto translation_of: Web/JavaScript/Reference/Global_Objects/Object/proto --- -
    +

    Warning: 基於現代Javascript引擎最佳化物件屬性存取的方法,改變一個物件的 [[Prototype]] 在任何瀏覽器或是Javascript引擎都是非常慢的操作?。改變繼承屬性對效能的影響微妙且深遠,不僅僅只是影響執行 obj.__proto__ = ... 的時間,而是會影響到所有有存取到被改變 [[Prototype]] 的物件的程式碼的執行時間。如果你在乎效能的話就應該避免改變一個物件的 [[Prototype]] 。反之,請用 {{jsxref("Object.create()")}} 來產生一個擁有 [[Prototype]] 的物件。

    -
    +

    Warning: 雖然 Object.prototype.__proto__ 在今日已經被絕大部分的瀏覽器所支援,其存在與確切的行為只有在 ECMAScript 2015 規範才被標準化成一個歷史功能來確保相容性。為了更好的支援,建議使用{{jsxref("Object.getPrototypeOf()")}}。

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/promise/finally/index.html b/files/zh-tw/web/javascript/reference/global_objects/promise/finally/index.html index d1d76d3d80..c4cf9ff4dc 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/promise/finally/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/promise/finally/index.html @@ -45,8 +45,8 @@ p.finally(function() { -
    -

    備註: 在 finally 回呼中使用 throw (或回傳 rejected promise)會導致新的 promise 被 reject , reject 的原因則是呼叫 throw() 時所指定的值。

    +
    +

    備註:在 finally 回呼中使用 throw (或回傳 rejected promise)會導致新的 promise 被 reject , reject 的原因則是呼叫 throw() 時所指定的值。

    Examples

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/promise/index.html b/files/zh-tw/web/javascript/reference/global_objects/promise/index.html index ec38359021..a434a6d4dd 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/promise/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/promise/index.html @@ -7,8 +7,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise

    Promise 物件代表一個即將完成、或失敗的非同步操作,以及它所產生的值。

    -
    -

    此條目為介紹 Promise 建構式。要瞭解 Promise 相關使用方式,請先參考使用 Promise。Promise 建構式主要用於包裹尚未支援 Promise 的函式。

    +
    +

    備註:此條目為介紹 Promise 建構式。要瞭解 Promise 相關使用方式,請先參考使用 Promise。Promise 建構式主要用於包裹尚未支援 Promise 的函式。

    {{EmbedInteractiveExample("pages/js/promise-constructor.html")}}
    @@ -42,12 +42,12 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise

    -
    -

    容易混淆: 許多其他語言擁有機制用來惰性求值(lazy evaluation)及延遲(deferring)運算,它們也被稱作“promises” — e.g. Scheme. 然而在 JavaScript 中 Promises 代表那些(已經)發生中(happening)的程序,它們可以繫結回呼函式。若您要找的是惰性求值表示式,考慮不帶參數的 arrow functionf = () => expression 來建立惰性求值表示式,並透過 f() 進行求值.

    +
    +

    備註: 許多其他語言擁有機制用來惰性求值(lazy evaluation)及延遲(deferring)運算,它們也被稱作“promises” — e.g. Scheme. 然而在 JavaScript 中 Promises 代表那些(已經)發生中(happening)的程序,它們可以繫結回呼函式。若您要找的是惰性求值表示式,考慮不帶參數的 arrow functionf = () => expression 來建立惰性求值表示式,並透過 f() 進行求值.

    -
    -

    Note: 一個被實現或拒絕,但不處於 pending 的 promise 被稱作被解決(settled)。您也會見到使用解決(resolved)一詞來描述 promises — 這代表 promises 被實現(fulfilled)了。States and fates 這篇文章包含了更多 promises 的專有名詞。

    +
    +

    備註:一個被實現或拒絕,但不處於 pending 的 promise 被稱作被解決(settled)。您也會見到使用解決(resolved)一詞來描述 promises — 這代表 promises 被實現(fulfilled)了。States and fates 這篇文章包含了更多 promises 的專有名詞。

    屬性

    @@ -181,7 +181,7 @@ function testPromise() { ') Promise made (<small>Sync code terminated</small>)<br/>'); }
    -

    *譯註:resolver function 即 executor function。

    +

    *譯註:resolver function 即 executor function。

    if ("Promise" in window) {
       let btn = document.getElementById("btn");
    diff --git a/files/zh-tw/web/javascript/reference/global_objects/promise/then/index.html b/files/zh-tw/web/javascript/reference/global_objects/promise/then/index.html
    index a77dab8014..3ceb57d196 100644
    --- a/files/zh-tw/web/javascript/reference/global_objects/promise/then/index.html
    +++ b/files/zh-tw/web/javascript/reference/global_objects/promise/then/index.html
    @@ -7,8 +7,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Promise/then
     
     

    then() 方法回傳一個 {{domxref("Promise")}} 物件。它接收兩個引數: Promise 在成功及失敗情況時的回呼函式。

    -
    -

    如果有一個或兩個引數被省略,或為非函式(non-functions),則 then 將處於遺失 handler(s) 的狀態,但不會產生錯誤。若發起 then 之 Promise 採取了一個狀態(實現(fulfillment)或拒絕(rejection))而 then 沒有處理它的函式,一個不具有額外 handlers 的新 Promise 物件將被建立,單純採取原 Promise 其最終狀態。

    +
    +

    備註:如果有一個或兩個引數被省略,或為非函式(non-functions),則 then 將處於遺失 handler(s) 的狀態,但不會產生錯誤。若發起 then 之 Promise 採取了一個狀態(實現(fulfillment)或拒絕(rejection))而 then 沒有處理它的函式,一個不具有額外 handlers 的新 Promise 物件將被建立,單純採取原 Promise 其最終狀態。

    語法

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/reflect/index.html b/files/zh-tw/web/javascript/reference/global_objects/reflect/index.html index 03cd63effc..7feb69f921 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/reflect/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/reflect/index.html @@ -46,81 +46,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Reflect

    規範

    - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES2015', '#sec-reflect-object', 'Reflect')}}{{Spec2('ES2015')}}Initial definition.
    {{SpecName('ESDraft', '#sec-reflect-object', 'Reflect')}}{{Spec2('ESDraft')}}Reflect.enumerate has been removed.
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(49.0)}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("42")}}{{CompatNo}}{{CompatNo}}{{CompatSafari(10)}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatChrome(49.0)}}{{CompatChrome(49.0)}}{{CompatVersionUnknown}}{{CompatGeckoMobile("42")}}{{CompatNo}}{{CompatNo}}{{CompatSafari(10)}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/set/has/index.html b/files/zh-tw/web/javascript/reference/global_objects/set/has/index.html index c77d2ea99b..9c6fd56418 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/set/has/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/set/has/index.html @@ -32,8 +32,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Set/has

    回傳 true 如果給定值存在在 Set 物件中;反之回傳 false

    -
    -

    Note: 技術上來說,has() 使用了 sameValueZero 算法來判斷給定元素的存在與否。

    +
    +

    備註:技術上來說,has() 使用了 sameValueZero 算法來判斷給定元素的存在與否。

    範例

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/string/index.html b/files/zh-tw/web/javascript/reference/global_objects/string/index.html index e29b6b8cea..2c9e419b04 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/string/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/string/index.html @@ -105,8 +105,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String
    -
    -

    和其他語言不同,JavaScript 將單引號字串和雙引號字串是做相同;因此,上述的序列可以在單引號或雙引號中作用。

    +
    +

    備註:和其他語言不同,JavaScript 將單引號字串和雙引號字串是做相同;因此,上述的序列可以在單引號或雙引號中作用。

    @@ -192,7 +192,7 @@ console.log(eval(s2)); // 回傳字串 "2 + 2"
    console.log(eval(s2.valueOf())); // 回傳數字 4
     
    -
    注意: 對於在 JavaScript 中其他可用的字串方法,請參閱這篇文章StringView – a C-like representation of strings based on typed arrays
    +

    備註:對於在 JavaScript 中其他可用的字串方法,請參閱這篇文章StringView – a C-like representation of strings based on typed arrays

    屬性

    @@ -216,8 +216,8 @@ console.log(eval(s2)); // 回傳字串 "2 + 2"

    String 通用方法

    -
    -

    字串通用方法是非標準化的、被棄用的,也有近期將被刪除的。

    +
    +

    警告:字串通用方法是非標準化的、被棄用的,也有近期將被刪除的。

    The String instance methods are also available in Firefox as of JavaScript 1.6 (though not part of the ECMAScript standard) on the String object for applying String methods to any object:

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/string/padstart/index.html b/files/zh-tw/web/javascript/reference/global_objects/string/padstart/index.html index bb053cd10a..e61013fb77 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/string/padstart/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/string/padstart/index.html @@ -31,63 +31,13 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/padStart 'abc'.padStart(6,"123465"); // "123abc"
    -

    Specifications

    +

    規範

    -

    這個方法還沒有被納入 ECMAScript 標準。現在還只是個提案

    +{{Specifications}} -

    Browser compatibility

    +

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(57)}} 15{{CompatGeckoDesktop(51)}}{{CompatNo}}{{CompatOpera(44)}}{{CompatSafari(10)}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatUnknown}}{{CompatChrome(57)}}{{CompatGeckoMobile(51)}}{{CompatUnknown}}{{CompatUnknown}}{{CompatSafari(10)}}
    -
    +{{Compat}}

    See also

    diff --git a/files/zh-tw/web/javascript/reference/global_objects/string/replace/index.html b/files/zh-tw/web/javascript/reference/global_objects/string/replace/index.html index 1cc9b1abac..b40013644c 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/string/replace/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/string/replace/index.html @@ -7,8 +7,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replace

    replace() 方法會傳回一個新字串,此新字串是透過將原字串與 pattern 比對,以 replacement 取代吻合處而生成。pattern 可以是字串或 {{jsxref("RegExp")}},而 replacement 可以是字串或函式(會在每一次匹配時被呼叫)。

    -
    -

    備註:原始的字串會保持不變。

    +
    +

    備註:原始的字串會保持不變。

    語法

    @@ -42,11 +42,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replace

    The replacement string can include the following special replacement patterns:

    - +
    - - + + @@ -77,11 +77,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/String/replace

    The arguments to the function are as follows:

    -
    PatternInsertsPatternInserts
    $$
    +
    - - + + diff --git a/files/zh-tw/web/javascript/reference/global_objects/typedarray/index.html b/files/zh-tw/web/javascript/reference/global_objects/typedarray/index.html index 49be1c3db0..56c14f39ba 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/typedarray/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/typedarray/index.html @@ -84,12 +84,12 @@ Int8Array.prototype.foo = 'bar';
    Possible nameSupplied valuePossible nameSupplied value
    match
    - - - - - - + + + + + + diff --git a/files/zh-tw/web/javascript/reference/global_objects/undefined/index.html b/files/zh-tw/web/javascript/reference/global_objects/undefined/index.html index f352c84d71..f183c412ce 100644 --- a/files/zh-tw/web/javascript/reference/global_objects/undefined/index.html +++ b/files/zh-tw/web/javascript/reference/global_objects/undefined/index.html @@ -26,8 +26,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/undefined

    A variable that has not been assigned a value is of type undefined. A method or statement also returns undefined if the variable that is being evaluated does not have an assigned value. A function returns undefined if a value was not {{jsxref("Statements/return", "returned")}}.

    -
    -

    While it is possible to use it as an {{Glossary("Identifier", "identifier")}} (variable name) in any scope other than the global scope (because undefined is not a {{jsxref("Reserved_Words", "reserved word")}}), doing so is a very bad idea that will make your code difficult to maintain and debug.

    +
    +

    Warning: While it is possible to use it as an {{Glossary("Identifier", "identifier")}} (variable name) in any scope other than the global scope (because undefined is not a {{jsxref("Reserved_Words", "reserved word")}}), doing so is a very bad idea that will make your code difficult to maintain and debug.

    //DON'T DO THIS
     
    @@ -54,8 +54,8 @@ else {
     }
     
    -
    -

    備註:The strict equality operator rather than the standard equality operator must be used here, because x == undefined also checks whether x is null, while strict equality doesn't. null is not equivalent to undefined. See {{jsxref("Operators/Comparison_Operators", "comparison operators")}} for details.

    +
    +

    Note: The strict equality operator rather than the standard equality operator must be used here, because x == undefined also checks whether x is null, while strict equality doesn't. null is not equivalent to undefined. See {{jsxref("Operators/Comparison_Operators", "comparison operators")}} for details.

    Typeof operator and undefined

    diff --git a/files/zh-tw/web/javascript/reference/index.html b/files/zh-tw/web/javascript/reference/index.html index a4de78261c..25a68dc221 100644 --- a/files/zh-tw/web/javascript/reference/index.html +++ b/files/zh-tw/web/javascript/reference/index.html @@ -14,270 +14,336 @@ translation_of: Web/JavaScript/Reference

    本章節記錄了所有 JavaScript 標準內建物件 以及其方法與屬性。

    -
      -
    • 數值屬性 - -

      {{JSxRef("Infinity")}}
      - {{JSxRef("NaN")}}
      - {{JSxRef("undefined")}}
      - {{JSxRef("globalThis")}}

      -
    • -
    • 函數屬性 -

      {{JSxRef("Global_Objects/eval", "eval()")}}
      - {{JSxRef("Global_Objects/isFinite", "isFinite()")}}
      - {{JSxRef("Global_Objects/isNaN", "isNaN()")}}
      - {{JSxRef("Global_Objects/parseFloat", "parseFloat()")}}
      - {{JSxRef("Global_Objects/parseInt", "parseInt()")}}
      - {{JSxRef("Global_Objects/decodeURI", "decodeURI()")}}
      - {{JSxRef("Global_Objects/decodeURIComponent", "decodeURIComponent()")}}
      - {{JSxRef("Global_Objects/encodeURI", "encodeURI()")}}
      - {{JSxRef("Global_Objects/encodeURIComponent", "encodeURIComponent()")}}

      -
    • -
    • 基礎物件 -

      {{JSxRef("Object")}}
      - {{JSxRef("Function")}}
      - {{JSxRef("Boolean")}}
      - {{JSxRef("Symbol")}}

      -
    • -
    • Error objects -

      {{JSxRef("Error")}}
      - {{JSxRef("AggregateError")}}
      - {{JSxRef("EvalError")}}
      - {{JSxRef("InternalError")}}
      - {{JSxRef("RangeError")}}
      - {{JSxRef("ReferenceError")}}
      - {{JSxRef("SyntaxError")}}
      - {{JSxRef("TypeError")}}
      - {{JSxRef("URIError")}}

      -
    • -
    - -
      -
    • 數字與日期 - -

      {{JSxRef("Number")}}
      - {{JSxRef("BigInt")}}
      - {{JSxRef("Math")}}
      - {{JSxRef("Date")}}

      -
    • -
    • 文字處理 -

      {{JSxRef("String")}}
      - {{JSxRef("RegExp")}}

      -
    • -
    • 具索引的集合 {{JSxRef("Array")}}
      - {{JSxRef("Int8Array")}}
      - {{JSxRef("Uint8Array")}}
      - {{JSxRef("Uint8ClampedArray")}}
      - {{JSxRef("Int16Array")}}
      - {{JSxRef("Uint16Array")}}
      - {{JSxRef("Int32Array")}}
      - {{JSxRef("Uint32Array")}}
      - {{JSxRef("Float32Array")}}
      - {{JSxRef("Float64Array")}}
      - {{JSxRef("BigInt64Array")}}
      - {{JSxRef("BigUint64Array")}}
    • -
    • 具鍵值的集合 -

      {{JSxRef("Map")}}
      - {{JSxRef("Set")}}
      - {{JSxRef("WeakMap")}}
      - {{JSxRef("WeakSet")}}

      -
    • -
    - -
      -
    • 結構化資料 - -

      {{JSxRef("ArrayBuffer")}}
      - {{JSxRef("SharedArrayBuffer")}}
      - {{JSxRef("Atomics")}}
      - {{JSxRef("DataView")}}
      - {{JSxRef("JSON")}}

      -
    • -
    • 控制抽象化物件 -

      {{JSxRef("Promise")}}
      - {{JSxRef("Generator")}}
      - {{JSxRef("GeneratorFunction")}}
      - {{JSxRef("AsyncFunction")}}

      -
    • -
    • Reflection -

      {{JSxRef("Reflect")}}
      - {{JSxRef("Proxy")}}

      -
    • -
    • 國際化 -

      {{JSxRef("Intl")}}
      - {{JSxRef("Global_Objects/Collator", "Intl.Collator")}}
      - {{JSxRef("Global_Objects/DateTimeFormat", "Intl.DateTimeFormat")}}
      - {{JSxRef("Global_Objects/ListFormat", "Intl.ListFormat")}}
      - {{JSxRef("Global_Objects/NumberFormat", "Intl.NumberFormat")}}
      - {{JSxRef("Global_Objects/PluralRules", "Intl.PluralRules")}}
      - {{JSxRef("Global_Objects/RelativeTimeFormat", "Intl.RelativeTimeFormat")}}
      - {{JSxRef("Global_Objects/Locale", "Intl.Locale")}}

      -
    • -
    - -
      -
    • WebAssembly - -

      {{JSxRef("WebAssembly")}}
      - {{JSxRef("WebAssembly.Module")}}
      - {{JSxRef("WebAssembly.Instance")}}
      - {{JSxRef("WebAssembly.Memory")}}
      - {{JSxRef("WebAssembly.Table")}}
      - {{JSxRef("WebAssembly.CompileError")}}
      - {{JSxRef("WebAssembly.LinkError")}}
      - {{JSxRef("WebAssembly.RuntimeError")}}

      -
    • +

      數值屬性

      + +
        +
      • {{JSxRef("Infinity")}}
      • +
      • {{JSxRef("NaN")}}
      • +
      • {{JSxRef("undefined")}}
      • +
      • {{JSxRef("globalThis")}}
      • +
      + +

      函數屬性

      + +
        +
      • {{JSxRef("Global_Objects/eval", "eval()")}}
      • +
      • {{JSxRef("Global_Objects/isFinite", "isFinite()")}}
      • +
      • {{JSxRef("Global_Objects/isNaN", "isNaN()")}}
      • +
      • {{JSxRef("Global_Objects/parseFloat", "parseFloat()")}}
      • +
      • {{JSxRef("Global_Objects/parseInt", "parseInt()")}}
      • +
      • {{JSxRef("Global_Objects/decodeURI", "decodeURI()")}}
      • +
      • {{JSxRef("Global_Objects/decodeURIComponent", "decodeURIComponent()")}}
      • +
      • {{JSxRef("Global_Objects/encodeURI", "encodeURI()")}}
      • +
      • {{JSxRef("Global_Objects/encodeURIComponent", "encodeURIComponent()")}}
      • +
      + +

      基礎物件

      + +
        +
      • {{JSxRef("Object")}}
      • +
      • {{JSxRef("Function")}}
      • +
      • {{JSxRef("Boolean")}}
      • +
      • {{JSxRef("Symbol")}}
      • +
      + +

      Error

      + +
        +
      • {{JSxRef("Error")}}
      • +
      • {{JSxRef("AggregateError")}}
      • +
      • {{JSxRef("EvalError")}}
      • +
      • {{JSxRef("InternalError")}}
      • +
      • {{JSxRef("RangeError")}}
      • +
      • {{JSxRef("ReferenceError")}}
      • +
      • {{JSxRef("SyntaxError")}}
      • +
      • {{JSxRef("TypeError")}}
      • +
      • {{JSxRef("URIError")}}
      • +
      + +

      數字與日期

      + +
        +
      • {{JSxRef("Number")}}
      • +
      • {{JSxRef("BigInt")}}
      • +
      • {{JSxRef("Math")}}
      • +
      • {{JSxRef("Date")}}
      • +
      + +

      文字處理

      + +
        +
      • {{JSxRef("String")}}
      • +
      • {{JSxRef("RegExp")}}
      • +
      + +

      具索引的集合

      + +
        +
      • {{JSxRef("Array")}}
      • +
      • {{JSxRef("Int8Array")}}
      • +
      • {{JSxRef("Uint8Array")}}
      • +
      • {{JSxRef("Uint8ClampedArray")}}
      • +
      • {{JSxRef("Int16Array")}}
      • +
      • {{JSxRef("Uint16Array")}}
      • +
      • {{JSxRef("Int32Array")}}
      • +
      • {{JSxRef("Uint32Array")}}
      • +
      • {{JSxRef("Float32Array")}}
      • +
      • {{JSxRef("Float64Array")}}
      • +
      • {{JSxRef("BigInt64Array")}}
      • +
      • {{JSxRef("BigUint64Array")}}
      • +
      + +

      具鍵值的集合

      + +
        +
      • {{JSxRef("Map")}}
      • +
      • {{JSxRef("Set")}}
      • +
      • {{JSxRef("WeakMap")}}
      • +
      • {{JSxRef("WeakSet")}}
      • +
      + +

      結構化資料

      + +
        +
      • {{JSxRef("ArrayBuffer")}}
      • +
      • {{JSxRef("SharedArrayBuffer")}}
      • +
      • {{JSxRef("Atomics")}}
      • +
      • {{JSxRef("DataView")}}
      • +
      • {{JSxRef("JSON")}}
      • +
      + +

      控制抽象化物件

      + +
        +
      • {{JSxRef("Promise")}}
      • +
      • {{JSxRef("Generator")}}
      • +
      • {{JSxRef("GeneratorFunction")}}
      • +
      • {{JSxRef("AsyncFunction")}}
      • +
      + +

      Reflection

      + +
        +
      • {{JSxRef("Reflect")}}
      • +
      • {{JSxRef("Proxy")}}
      • +
      + +

      國際化

      + +
        +
      • {{JSxRef("Intl")}}
      • +
      • {{JSxRef("Global_Objects/Collator", "Intl.Collator")}}
      • +
      • {{JSxRef("Global_Objects/DateTimeFormat", "Intl.DateTimeFormat")}}
      • +
      • {{JSxRef("Global_Objects/ListFormat", "Intl.ListFormat")}}
      • +
      • {{JSxRef("Global_Objects/NumberFormat", "Intl.NumberFormat")}}
      • +
      • {{JSxRef("Global_Objects/PluralRules", "Intl.PluralRules")}}
      • +
      • {{JSxRef("Global_Objects/RelativeTimeFormat", "Intl.RelativeTimeFormat")}}
      • +
      • {{JSxRef("Global_Objects/Locale", "Intl.Locale")}}
      • +
      + +

      WebAssembly

      + +
        +
      • {{JSxRef("WebAssembly")}}
      • +
      • {{JSxRef("WebAssembly.Module")}}
      • +
      • {{JSxRef("WebAssembly.Instance")}}
      • +
      • {{JSxRef("WebAssembly.Memory")}}
      • +
      • {{JSxRef("WebAssembly.Table")}}
      • +
      • {{JSxRef("WebAssembly.CompileError")}}
      • +
      • {{JSxRef("WebAssembly.LinkError")}}
      • +
      • {{JSxRef("WebAssembly.RuntimeError")}}

      敘述句

      本章節記錄了所有 JavaScript 敘述句與宣告

      -
        -
      • 流程控制{{jsxref("Statements/block", "Block")}}
        - {{jsxref("Statements/break", "break")}}
        - {{jsxref("Statements/continue", "continue")}}
        - {{jsxref("Statements/Empty", "Empty")}}
        - {{jsxref("Statements/if...else", "if...else")}}
        - {{jsxref("Statements/switch", "switch")}}
        - {{jsxref("Statements/throw", "throw")}}
        - {{jsxref("Statements/try...catch", "try...catch")}}
      • -
      • 宣告 -

        {{jsxref("Statements/var", "var")}}
        - {{jsxref("Statements/let", "let")}}
        - {{jsxref("Statements/const", "const")}}

        -
      • -
      • 函數與類別 -

        {{jsxref("Statements/function", "function")}}
        - {{jsxref("Statements/function*", "function*")}}
        - {{jsxref("Statements/async_function", "async function")}}
        - {{jsxref("Statements/return", "return")}}
        - {{jsxref("Statements/class", "class")}}

        -
      • -
      • 迭代 -

        {{jsxref("Statements/do...while", "do...while")}}
        - {{jsxref("Statements/for", "for")}}
        - {{jsxref("Statements/for_each...in", "for each...in")}}
        - {{jsxref("Statements/for...in", "for...in")}}
        - {{jsxref("Statements/for...of", "for...of")}}
        - {{jsxref("Statements/for-await...of", "for await...of")}}
        - {{jsxref("Statements/while", "while")}}

        -
      • -
      - -
        -
      • Other - -

        {{jsxref("Statements/debugger", "debugger")}}
        - {{jsxref("Statements/import", "import")}}
        - {{jsxref("Statements/label", "label")}}
        - {{jsxref("Statements/with", "with")}}

        -
      • +

        流程控制

        + +
          +
        • {{jsxref("Statements/block", "Block")}}
        • +
        • {{jsxref("Statements/break", "break")}}
        • +
        • {{jsxref("Statements/continue", "continue")}}
        • +
        • {{jsxref("Statements/Empty", "Empty")}}
        • +
        • {{jsxref("Statements/if...else", "if...else")}}
        • +
        • {{jsxref("Statements/switch", "switch")}}
        • +
        • {{jsxref("Statements/throw", "throw")}}
        • +
        • {{jsxref("Statements/try...catch", "try...catch")}}
        • +
        + +

        宣告

        + +
          +
        • {{jsxref("Statements/var", "var")}}
        • +
        • {{jsxref("Statements/let", "let")}}
        • +
        • {{jsxref("Statements/const", "const")}}
        • +
        + +

        函數與類別

        + +
          +
        • {{jsxref("Statements/function", "function")}}
        • +
        • {{jsxref("Statements/function*", "function*")}}
        • +
        • {{jsxref("Statements/async_function", "async function")}}
        • +
        • {{jsxref("Statements/return", "return")}}
        • +
        • {{jsxref("Statements/class", "class")}}
        • +
        + +

        迭代

        + +
          +
        • {{jsxref("Statements/do...while", "do...while")}}
        • +
        • {{jsxref("Statements/for", "for")}}
        • +
        • {{jsxref("Statements/for_each...in", "for each...in")}}
        • +
        • {{jsxref("Statements/for...in", "for...in")}}
        • +
        • {{jsxref("Statements/for...of", "for...of")}}
        • +
        • {{jsxref("Statements/for-await...of", "for await...of")}}
        • +
        • {{jsxref("Statements/while", "while")}}
        • +
        + +

        Other

        + +
          +
        • {{jsxref("Statements/debugger", "debugger")}}
        • +
        • {{jsxref("Statements/import", "import")}}
        • +
        • {{jsxref("Statements/label", "label")}}
        • +
        • {{jsxref("Statements/with", "with")}}

        表示法與運算子

        本章節記錄了所有 JavaScript 表示法與運算子

        -
        -
          -
        • 主要運算式{{JSxRef("Operators/this", "this")}}
          - {{JSxRef("Operators/function", "function")}}
          - {{JSxRef("Operators/class", "class")}}
          - {{JSxRef("Operators/function*", "function*")}}
          - {{JSxRef("Operators/yield", "yield")}}
          - {{JSxRef("Operators/yield*", "yield*")}}
          - {{JSxRef("Operators/async_function", "async function")}}
          - {{JSxRef("Operators/await", "await")}}
          - {{JSxRef("Global_Objects/Array", "[]")}}
          - {{JSxRef("Operators/Object_initializer", "{}")}}
          - {{JSxRef("Global_Objects/RegExp", "/ab+c/i")}}
          - {{JSxRef("Operators/Grouping", "( )")}}
          - {{JSxRef("null")}}
        • -
        • 左手邊運算式 -

          {{JSxRef("Operators/Property_accessors", "Property accessors", "", 1)}}
          - {{JSxRef("Operators/new", "new")}}
          - {{JSxRef("Operators/new%2Etarget", "new.target")}}
          - {{JSxRef("Operators/super", "super")}}
          - {{JSxRef("Operators/Spread_syntax", "...obj")}}

          -
        • -
        • 遞增與遞減 -

          {{JSxRef("Operators/Arithmetic_Operators", "A++", "#Increment")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "A--", "#Decrement")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "++A", "#Increment")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "--A", "#Decrement")}}

          -
        • -
        • 一元運算子 -

          {{JSxRef("Operators/delete", "delete")}}
          - {{JSxRef("Operators/void", "void")}}
          - {{JSxRef("Operators/typeof", "typeof")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "+", "#Unary_plus")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "-", "#Unary_negation")}}
          - {{JSxRef("Operators/Bitwise_Operators", "~", "#Bitwise_NOT")}}
          - {{JSxRef("Operators/Logical_Operators", "!", "#Logical_NOT")}}

          -
        • -
        - -
          -
        • 算術運算子 - -

          {{JSxRef("Operators/Arithmetic_Operators", "+", "#Addition")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "-", "#Subtraction")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "/", "#Division")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "*", "#Multiplication")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "%", "#Remainder")}}
          - {{JSxRef("Operators/Arithmetic_Operators", "**", "#Exponentiation")}}

          -
        • -
        • 關係運算子 -

          {{JSxRef("Operators/in", "in")}}
          - {{JSxRef("Operators/instanceof", "instanceof")}}
          - {{JSxRef("Operators/Comparison_Operators", "<", "#Less_than_operator")}}
          - {{JSxRef("Operators/Comparison_Operators", ">", "#Greater_than_operator")}}
          - {{JSxRef("Operators/Comparison_Operators", "<=", "#Less_than_or_equal_operator")}}
          - {{JSxRef("Operators/Comparison_Operators", ">=", "#Greater_than_or_equal_operator")}}

          -
        • -
        • 相等運算子 -

          {{JSxRef("Operators/Comparison_Operators", "==", "#Equality")}}
          - {{JSxRef("Operators/Comparison_Operators", "!=", "#Inequality")}}
          - {{JSxRef("Operators/Comparison_Operators", "===", "#Identity")}}
          - {{JSxRef("Operators/Comparison_Operators", "!==", "#Nonidentity")}}

          -
        • -
        • 位元移位運算子 -

          {{JSxRef("Operators/Bitwise_Operators", "<<", "#Left_shift")}}
          - {{JSxRef("Operators/Bitwise_Operators", ">>", "#Right_shift")}}
          - {{JSxRef("Operators/Bitwise_Operators", ">>>", "#Unsigned_right_shift")}}

          -
        • -
        - -
          -
        • 二元位元運算子{{JSxRef("Operators/Bitwise_Operators", "&", "#Bitwise_AND")}}
          - {{JSxRef("Operators/Bitwise_Operators", "|", "#Bitwise_OR")}}
          - {{JSxRef("Operators/Bitwise_Operators", "^", "#Bitwise_XOR")}}
        • -
        • 二元邏輯運算子 -

          {{JSxRef("Operators/Logical_Operators", "&&", "#Logical_AND")}}
          - {{JSxRef("Operators/Logical_Operators", "||", "#Logical_OR")}}

          -
        • -
        • 條件(三元)運算子 -

          {{JSxRef("Operators/Conditional_Operator", "(condition ? ifTrue : ifFalse)")}}

          -
        • -
        • 賦值運算子 -

          {{JSxRef("Operators/Assignment_Operators", "=", "#Assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", "*=", "#Multiplication_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", "/=", "#Division_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", "%=", "#Remainder_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", "+=", "#Addition_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", "-=", "#Subtraction_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", "<<=", "#Left_shift_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", ">>=", "#Right_shift_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", ">>>=", "#Unsigned_right_shift_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", "&=", "#Bitwise_AND_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", "^=", "#Bitwise_XOR_assignment")}}
          - {{JSxRef("Operators/Assignment_Operators", "|=", "#Bitwise_OR_assignment")}}
          - {{JSxRef("Operators/Destructuring_assignment", "[a, b] = [1, 2]")}}
          - {{JSxRef("Operators/Destructuring_assignment", "{a, b} = {a:1, b:2}")}}

          -
        • -
        -
        +

        主要運算式

        + +
          +
        • {{JSxRef("Operators/this", "this")}}
        • +
        • {{JSxRef("Operators/function", "function")}}
        • +
        • {{JSxRef("Operators/class", "class")}}
        • +
        • {{JSxRef("Operators/function*", "function*")}}
        • +
        • {{JSxRef("Operators/yield", "yield")}}
        • +
        • {{JSxRef("Operators/yield*", "yield*")}}
        • +
        • {{JSxRef("Operators/async_function", "async function")}}
        • +
        • {{JSxRef("Operators/await", "await")}}
        • +
        • {{JSxRef("Global_Objects/Array", "[]")}}
        • +
        • {{JSxRef("Operators/Object_initializer", "{}")}}
        • +
        • {{JSxRef("Global_Objects/RegExp", "/ab+c/i")}}
        • +
        • {{JSxRef("Operators/Grouping", "( )")}}
        • +
        • {{JSxRef("null")}}
        • +
        + +

        左手邊運算式

        + +
          +
        • {{JSxRef("Operators/Property_accessors", "Property accessors", "", 1)}}
        • +
        • {{JSxRef("Operators/new", "new")}}
        • +
        • {{JSxRef("Operators/new%2Etarget", "new.target")}}
        • +
        • {{JSxRef("Operators/super", "super")}}
        • +
        • {{JSxRef("Operators/Spread_syntax", "...obj")}}

        • +
        + +

        遞增與遞減

        + +
          +
        • {{JSxRef("Operators/Arithmetic_Operators", "A++", "#Increment")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "A--", "#Decrement")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "++A", "#Increment")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "--A", "#Decrement")}}
        • +
        + +

        一元運算子

        + +
          +
        • {{JSxRef("Operators/delete", "delete")}}
        • +
        • {{JSxRef("Operators/void", "void")}}
        • +
        • {{JSxRef("Operators/typeof", "typeof")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "+", "#Unary_plus")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "-", "#Unary_negation")}}
        • +
        • {{JSxRef("Operators/Bitwise_Operators", "~", "#Bitwise_NOT")}}
        • +
        • {{JSxRef("Operators/Logical_Operators", "!", "#Logical_NOT")}}
        • +
        + +

        算術運算子

        + +
          +
        • {{JSxRef("Operators/Arithmetic_Operators", "+", "#Addition")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "-", "#Subtraction")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "/", "#Division")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "*", "#Multiplication")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "%", "#Remainder")}}
        • +
        • {{JSxRef("Operators/Arithmetic_Operators", "**", "#Exponentiation")}}
        • +
        + +

        關係運算子

        + +
          +
        • {{JSxRef("Operators/in", "in")}}
        • +
        • {{JSxRef("Operators/instanceof", "instanceof")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "<", "#Less_than_operator")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", ">", "#Greater_than_operator")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "<=", "#Less_than_or_equal_operator")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", ">=", "#Greater_than_or_equal_operator")}}
        • +
        + +

        相等運算子

        + +
          +
        • {{JSxRef("Operators/Comparison_Operators", "==", "#Equality")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "!=", "#Inequality")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "===", "#Identity")}}
        • +
        • {{JSxRef("Operators/Comparison_Operators", "!==", "#Nonidentity")}}
        • +
        + +

        位元移位運算子

        + +
          +
        • {{JSxRef("Operators/Bitwise_Operators", "<<", "#Left_shift")}}
        • +
        • {{JSxRef("Operators/Bitwise_Operators", ">>", "#Right_shift")}}
        • +
        • {{JSxRef("Operators/Bitwise_Operators", ">>>", "#Unsigned_right_shift")}}
        • +
        + +

        二元位元運算子

        + +
          +
            +
          • {{JSxRef("Operators/Bitwise_Operators", "&", "#Bitwise_AND")}}
          • +
          • {{JSxRef("Operators/Bitwise_Operators", "|", "#Bitwise_OR")}}
          • +
          • {{JSxRef("Operators/Bitwise_Operators", "^", "#Bitwise_XOR")}}
          • +
          +
        + +

        二元邏輯運算子

        + +
          +
        • {{JSxRef("Operators/Logical_Operators", "&&", "#Logical_AND")}}
        • +
        • {{JSxRef("Operators/Logical_Operators", "||", "#Logical_OR")}}
        • +
        + +

        條件(三元)運算子

        + +
          +
        • {{JSxRef("Operators/Conditional_Operator", "(condition ? ifTrue : ifFalse)")}}
        • +
        + +

        賦值運算子

        + +
          +
        • {{JSxRef("Operators/Assignment_Operators", "=", "#Assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "*=", "#Multiplication_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "/=", "#Division_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "%=", "#Remainder_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "+=", "#Addition_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "-=", "#Subtraction_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "<<=", "#Left_shift_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", ">>=", "#Right_shift_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", ">>>=", "#Unsigned_right_shift_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "&=", "#Bitwise_AND_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "^=", "#Bitwise_XOR_assignment")}}
        • +
        • {{JSxRef("Operators/Assignment_Operators", "|=", "#Bitwise_OR_assignment")}}
        • +
        • {{JSxRef("Operators/Destructuring_assignment", "[a, b] = [1, 2]")}}
        • +
        • {{JSxRef("Operators/Destructuring_assignment", "{a, b} = {a:1, b:2}")}}
        • +
        +

        函數

        diff --git a/files/zh-tw/web/javascript/reference/iteration_protocols/index.html b/files/zh-tw/web/javascript/reference/iteration_protocols/index.html index 707da81524..8c360e0894 100644 --- a/files/zh-tw/web/javascript/reference/iteration_protocols/index.html +++ b/files/zh-tw/web/javascript/reference/iteration_protocols/index.html @@ -71,8 +71,8 @@ translation_of: Web/JavaScript/Reference/Iteration_protocols
    TypeValue RangeSize in bytesDescriptionWeb IDL typeEquivalent C typeTypeValue RangeSize in bytesDescriptionWeb IDL typeEquivalent C type
    {{jsxref("Int8Array")}}
    -
    -

    我們無法反射性的一眼看出一個特定的物件是否實作了迭代器協議,然而要建立一個同時滿足迭代器及可迭代協議的物件卻是相當容易(如下例所示)。範例的做法允許一個迭代器被各個預期其可迭代行為的語法所消費。因此很少有需要實作迭代器協議而沒有實作可迭代協議的情況。

    +
    +

    備註:我們無法反射性的一眼看出一個特定的物件是否實作了迭代器協議,然而要建立一個同時滿足迭代器及可迭代協議的物件卻是相當容易(如下例所示)。範例的做法允許一個迭代器被各個預期其可迭代行為的語法所消費。因此很少有需要實作迭代器協議而沒有實作可迭代協議的情況。

    var myIterator = {
         next: function() {
    diff --git a/files/zh-tw/web/javascript/reference/operators/await/index.html b/files/zh-tw/web/javascript/reference/operators/await/index.html
    index dd1121503f..dea65636a8 100644
    --- a/files/zh-tw/web/javascript/reference/operators/await/index.html
    +++ b/files/zh-tw/web/javascript/reference/operators/await/index.html
    @@ -70,78 +70,11 @@ f3();

    規範

    - - - - - - - - - - - - - - - -
    規範狀態註解
    {{SpecName('ESDraft', '#sec-async-function-definitions', 'async functions')}}{{Spec2('ESDraft')}}ES2017中初始定義
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerEdgeOperaSafari (WebKit)
    基本支援{{CompatChrome(55)}}{{CompatGeckoDesktop("52.0")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatOpera(42)}}10.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidAndroid WebviewFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
    基本支援{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("52.0")}}{{CompatUnknown}}{{CompatOpera(42)}}10.1{{CompatChrome(55)}}
    -
    +{{Compat}}

    See also

    diff --git a/files/zh-tw/web/javascript/reference/operators/comma_operator/index.html b/files/zh-tw/web/javascript/reference/operators/comma_operator/index.html index e1c45ea5b0..f48dc17505 100644 --- a/files/zh-tw/web/javascript/reference/operators/comma_operator/index.html +++ b/files/zh-tw/web/javascript/reference/operators/comma_operator/index.html @@ -28,7 +28,7 @@ translation_of: Web/JavaScript/Reference/Operators/Comma_Operator

    The following code prints the values of the diagonal elements in the array:

    -
    for (var i = 0, j = 9; i <= 9; i++, j--)
    +
    for (var i = 0, j = 9; i <= 9; i++, j--)
       console.log("a[" + i + "][" + j + "] = " + a[i][j]);

    Note that the comma in assignments such as the var statement may appear not to have the normal effect of comma operators because they don't exist within an expression. In the following example, a is set to the value of b = 3 (which is 3), but the c = 4 expression still evaluates and its result returned to console (i.e., 4). This is due to operator precedence and associativity.

    @@ -56,87 +56,11 @@ console.log(x); // 6 (right-most)

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ESDraft', '#sec-comma-operator', 'Comma operator')}}{{Spec2('ESDraft')}} 
    {{SpecName('ES6', '#sec-comma-operator', 'Comma operator')}}{{Spec2('ES6')}} 
    {{SpecName('ES5.1', '#sec-11.14', 'Comma operator')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES1', '#sec-11.14', 'Comma operator')}}{{Spec2('ES1')}}Initial definition
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}3.0{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/operators/destructuring_assignment/index.html b/files/zh-tw/web/javascript/reference/operators/destructuring_assignment/index.html index 0cae43e2b5..c582226725 100644 --- a/files/zh-tw/web/javascript/reference/operators/destructuring_assignment/index.html +++ b/files/zh-tw/web/javascript/reference/operators/destructuring_assignment/index.html @@ -200,8 +200,8 @@ console.log(q); // true ({a, b} = {a:1, b:2});
    -
    -

    注意:當針對物件進行解構,而該句式沒有進行宣告時,指派式外必須加上括號 ( ... )

    +
    +

    備註:當針對物件進行解構,而該句式沒有進行宣告時,指派式外必須加上括號 ( ... )

    {a, b} = {a: 1, b: 2} 不是有效的獨立語法,因為左邊的 {a, b} 被視為程式碼區塊而非物件。

    @@ -277,8 +277,8 @@ drawChart({ radius: 30 }); -
    -

    在上述函式 drawChart 中,左方之解構式被指派到一個空物件: {size = 'big', coords = {x: 0, y: 0}, radius = 25} = {} 。你也可以略過填寫右方的指派式。不過,當你沒有使用右方指派式時,函式在呼叫時會找出最少一個參數。透過上述形式,你可以直接不使用參數的呼叫 drawChart() 。當你希望在呼叫這個函式時不傳送參數,這個設計會帶來方便。而另一個設計則能讓你確保函式必須傳上一個物件作為參數。

    +
    +

    備註:在上述函式 drawChart 中,左方之解構式被指派到一個空物件: {size = 'big', coords = {x: 0, y: 0}, radius = 25} = {} 。你也可以略過填寫右方的指派式。不過,當你沒有使用右方指派式時,函式在呼叫時會找出最少一個參數。透過上述形式,你可以直接不使用參數的呼叫 drawChart() 。當你希望在呼叫這個函式時不傳送參數,這個設計會帶來方便。而另一個設計則能讓你確保函式必須傳上一個物件作為參數。

    巢狀物件或陣列的解構

    diff --git a/files/zh-tw/web/javascript/reference/operators/index.html b/files/zh-tw/web/javascript/reference/operators/index.html index 6d27e8d2a5..efaf3d991d 100644 --- a/files/zh-tw/web/javascript/reference/operators/index.html +++ b/files/zh-tw/web/javascript/reference/operators/index.html @@ -138,8 +138,8 @@ translation_of: Web/JavaScript/Reference/Operators
    大於等於運算子。
    -
    -

    Note: => is not an operator, but the notation for Arrow functions.

    +
    +

    Note: => is not an operator, but the notation for Arrow functions.

    相等運算子

    diff --git a/files/zh-tw/web/javascript/reference/operators/object_initializer/index.html b/files/zh-tw/web/javascript/reference/operators/object_initializer/index.html index 5ce80cd8e8..436aa0fdfe 100644 --- a/files/zh-tw/web/javascript/reference/operators/object_initializer/index.html +++ b/files/zh-tw/web/javascript/reference/operators/object_initializer/index.html @@ -248,178 +248,11 @@ assert(obj3.__proto__ === 17);

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES1')}}{{Spec2('ES1')}}initial definition.
    {{SpecName('ES5.1', '#sec-11.1.5', 'Object Initializer')}}{{Spec2('ES5.1')}}getter and setter added.
    {{SpecName('ES2015', '#sec-object-initializer', 'Object Initializer')}}{{Spec2('ES2015')}}Shorthand method/property names and computed property names added.
    {{SpecName('ESDraft', '#sec-object-initializer', 'Object Initializer')}}{{Spec2('ESDraft')}} 
    Rest/Spread Properties for ECMAScript DraftStage 3 draft.
    +{{Specifications}}

    瀏覽器相容性

    -
    {{CompatibilityTable}}
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatChrome(1.0)}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("1.0")}}111
    Computed property names{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("34")}}{{CompatNo}}347.1
    Shorthand property names{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("33")}}{{CompatNo}}349
    Shorthand method names{{CompatChrome(42.0)}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("34")}}{{CompatNo}}349
    Spread properties{{CompatChrome(60)}}{{CompatNo}}{{CompatGeckoDesktop("55")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidAndroid WebviewEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari MobileChrome for Android
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("1.0")}}111{{CompatChrome(1.0)}}
    Computed property names{{CompatNo}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("34")}}{{CompatNo}}347.1{{CompatNo}}
    Shorthand property names{{CompatNo}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("33")}}{{CompatNo}}349{{CompatNo}}
    Shorthand method names{{CompatNo}}{{CompatChrome(42.0)}}{{CompatVersionUnknown}}{{CompatGeckoMobile("34")}}{{CompatNo}}349{{CompatChrome(42.0)}}
    Spread properties{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("55")}}{{CompatNo}}{{CompatNo}}{{CompatNo}}{{CompatNo}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/operators/operator_precedence/index.html b/files/zh-tw/web/javascript/reference/operators/operator_precedence/index.html index 0395059d09..2e3592d41a 100644 --- a/files/zh-tw/web/javascript/reference/operators/operator_precedence/index.html +++ b/files/zh-tw/web/javascript/reference/operators/operator_precedence/index.html @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Operators/Operator_Precedence

    下方表格列出運算子的相依性,從高 (20) 到低 (1)。

    - +
    優先性
    diff --git a/files/zh-tw/web/javascript/reference/operators/optional_chaining/index.html b/files/zh-tw/web/javascript/reference/operators/optional_chaining/index.html index 715161eca9..7326405696 100644 --- a/files/zh-tw/web/javascript/reference/operators/optional_chaining/index.html +++ b/files/zh-tw/web/javascript/reference/operators/optional_chaining/index.html @@ -61,8 +61,8 @@ let nestedProp = ((temp === null || temp === undefined) ? undefined : temp.secon
    let result = someInterface.customMethod?.();
    -
    -

    注意: 假如物件有同樣的屬性名稱,而不是一個方法,使用 ?. 將會抛出 {{JSxRef("TypeError")}} 錯誤(x.y 不是一個函數.

    +
    +

    備註:假如物件有同樣的屬性名稱,而不是一個方法,使用 ?. 將會抛出 {{JSxRef("TypeError")}} 錯誤(x.y 不是一個函數.

    處理回呼函式或事件處理器

    diff --git a/files/zh-tw/web/javascript/reference/operators/spread_syntax/index.html b/files/zh-tw/web/javascript/reference/operators/spread_syntax/index.html index 6b69748661..a9d0af6472 100644 --- a/files/zh-tw/web/javascript/reference/operators/spread_syntax/index.html +++ b/files/zh-tw/web/javascript/reference/operators/spread_syntax/index.html @@ -111,7 +111,7 @@ arr2.push(4); // arr remains unaffected -
    +

    Note: Spread syntax effectively goes one level deep while copying an array. Therefore, it may be unsuitable for copying multidimensional arrays, as the following example shows. (The same is true with {{jsxref("Object.assign()")}} and spread syntax.)

    const a = [[1], [2], [3]];
    @@ -165,7 +165,7 @@ arr1 = [...arr2, ...arr1];
     //  arr1 is now [3, 4, 5, 0, 1, 2]
     
    -
    +

    Note: Unlike unshift(), this creates a new arr1, and does not modify the original arr1 array in-place.

    diff --git a/files/zh-tw/web/javascript/reference/operators/this/index.html b/files/zh-tw/web/javascript/reference/operators/this/index.html index 9c99fb42f2..1dd3d43d4e 100644 --- a/files/zh-tw/web/javascript/reference/operators/this/index.html +++ b/files/zh-tw/web/javascript/reference/operators/this/index.html @@ -65,8 +65,8 @@ f2() === undefined; //true

    所以在嚴格模式下,如果 this 沒有定義到執行環境內,其預設值就會是 undefined

    -
    -

    在第二個例子裡面,this 應為 undefined,因為 f2 是直接被呼叫,而不是在其為某個物件的方法或屬性的情況下(例如 window.f2())被直接呼叫。某些瀏覽器首次支援嚴格模式時沒導入這個特徵,它們會因此錯誤的回傳 window 物件。

    +
    +

    備註:在第二個例子裡面,this 應為 undefined,因為 f2 是直接被呼叫,而不是在其為某個物件的方法或屬性的情況下(例如 window.f2())被直接呼叫。某些瀏覽器首次支援嚴格模式時沒導入這個特徵,它們會因此錯誤的回傳 window 物件。

    要從某個語境訪問另一個 this 語境的值,請使用 callapply:

    @@ -138,8 +138,8 @@ console.log(o.f(), o.g(), o.h()); // 37, azerty, azerty var foo = (() => this); console.log(foo() === globalObject); // true -
    -

    註:如果這參數被傳遞給箭頭函式的 call, bind, apply 調用,該參數會被忽略。你仍然可以將參數預先調用到call,但第一個參數(thisArg)必須設置為空。

    +
    +

    備註:如果這參數被傳遞給箭頭函式的 call, bind, apply 調用,該參數會被忽略。你仍然可以將參數預先調用到call,但第一個參數(thisArg)必須設置為空。

    // 作為物件的方法呼叫
    @@ -253,8 +253,8 @@ console.log(o.average, o.sum); // logs 2, 6
     
     

    若函式以建構子的身份呼叫(使用 new 關鍵字) this 會和被建構的新物件綁定。

    -
    -

    建構子預設透過 this 回傳該物件的參照,但它其實能回傳其他物件。如果回傳值不是物件的話,就會回傳 this 這個物件。

    +
    +

    備註:建構子預設透過 this 回傳該物件的參照,但它其實能回傳其他物件。如果回傳值不是物件的話,就會回傳 this 這個物件。

    /*
    diff --git a/files/zh-tw/web/javascript/reference/operators/typeof/index.html b/files/zh-tw/web/javascript/reference/operators/typeof/index.html
    index e7f4c388e8..f9bb266a74 100644
    --- a/files/zh-tw/web/javascript/reference/operators/typeof/index.html
    +++ b/files/zh-tw/web/javascript/reference/operators/typeof/index.html
    @@ -144,8 +144,8 @@ typeof Math.sin === 'function';
     
     

    這個問題已計畫在下一版 ECMAScript 予以修正 (會以 opt-in 方式提供). 屆時它將會做出如 typeof null === 'null' 的正確回傳結果。

    -
    -

    註: 此修正計畫已被拒絕

    +
    +

    備註:此修正計畫已被拒絕

    正規表示式 (Regular expressions)

    @@ -162,8 +162,8 @@ typeof /s/ === 'object'; // Firefox 5+ ... // 符合 ECMAScript 5.1

    在 IE 6, 7 和 8, typeof alert === 'object'

    -
    -

    註: 這並不怪異。這是實情。在許多較舊的 IE 中, 主機端物件的確是物件, 而非函數

    +
    +

    備註:這並不怪異。這是實情。在許多較舊的 IE 中, 主機端物件的確是物件, 而非函數

    規格

    diff --git a/files/zh-tw/web/javascript/reference/statements/async_function/index.html b/files/zh-tw/web/javascript/reference/statements/async_function/index.html index 1111e54da6..7faf5dcfef 100644 --- a/files/zh-tw/web/javascript/reference/statements/async_function/index.html +++ b/files/zh-tw/web/javascript/reference/statements/async_function/index.html @@ -45,8 +45,8 @@ translation_of: Web/JavaScript/Reference/Statements/async_function

    async 函式內部可以使用 {{jsxref("Operators/await", "await")}} 表達式,它會暫停此 async 函式的執行,並且等待傳遞至表達式的 Promise 的解析,解析完之後會回傳解析值,並繼續此 async 函式的執行。

    -
    -

    async/await 函式的目的在於簡化同步操作 promise 的表現,以及對多個 Promise 物件執行某些操作。就像 Promise 類似於具結構性的回呼函式,同樣地,async/await 好比將 generator 與 promise 組合起來。

    +
    +

    備註:async/await 函式的目的在於簡化同步操作 promise 的表現,以及對多個 Promise 物件執行某些操作。就像 Promise 類似於具結構性的回呼函式,同樣地,async/await 好比將 generator 與 promise 組合起來。

    範例

    @@ -84,8 +84,8 @@ add2(10).then(v => { });
    -
    -

    不要誤解 Promise.allawait

    +
    +

    警告:不要誤解 Promise.allawait

    add1 裡,該執行為了第一個 await 而暫停了兩秒,接著為了第二個 await 又暫停了兩秒。在第一個計時器(timer)被觸發前,第二個計時器並不會被建立。而在 add2 裡,兩個計時器都被建立起來、也都執行 await 過了。這把它帶往了 resolve 所的 2 秒暫停、而不是 4 秒暫停。然而這兩個 await 呼叫都在連續運行,而非平行運行。await 並不是 Promise.all 的自動程式。如果你想讓兩個、甚至兩個以上的 await promises 同時執行(in parallel),你必須使用 Promise.all.

    diff --git a/files/zh-tw/web/javascript/reference/statements/block/index.html b/files/zh-tw/web/javascript/reference/statements/block/index.html index 0e1d2ce662..a62ff2583e 100644 --- a/files/zh-tw/web/javascript/reference/statements/block/index.html +++ b/files/zh-tw/web/javascript/reference/statements/block/index.html @@ -12,7 +12,7 @@ translation_of: Web/JavaScript/Reference/Statements/block - + @@ -63,7 +63,7 @@ alert(x); // outputs 2

    當使用let或是const進行宣告時,其存取範圍是只有本身定義的區塊中。

    -
    let x = 1;
    +
    let x = 1;
     {
       let x = 2;
     }
    diff --git a/files/zh-tw/web/javascript/reference/statements/break/index.html b/files/zh-tw/web/javascript/reference/statements/break/index.html
    index ff72f9d25b..b5fa73113e 100644
    --- a/files/zh-tw/web/javascript/reference/statements/break/index.html
    +++ b/files/zh-tw/web/javascript/reference/statements/break/index.html
    @@ -25,13 +25,13 @@ translation_of: Web/JavaScript/Reference/Statements/break
     
     

    說明

    -

    中斷陳述 break 可加上標籤 (label) 參數,使其跳出被標籤的陳述語句。此中斷陳述 break 必須被包含在被標籤的陳述語句中。被標籤的陳述語句可被添加於任一個區塊 (block) 前,而非限定在迴圈陳述。

    +

    中斷陳述 break 可加上標籤 (label) 參數,使其跳出被標籤的陳述語句。此中斷陳述 break 必須被包含在被標籤的陳述語句中。被標籤的陳述語句可被添加於任一個區塊 (block) 前,而非限定在迴圈陳述。

    範例

    下面函式包含一個中斷陳述 break ,當 i 值為 3 時,中斷 while 迴圈,並回傳 3 * x

    -
    function testBreak(x) {
    +
    function testBreak(x) {
       var i = 0;
     
       while (i < 6) {
    @@ -46,7 +46,7 @@ translation_of: Web/JavaScript/Reference/Statements/break
     
     

    The following code uses break statements with labeled blocks. A break statement must be nested within any label it references. Notice that inner_block is nested within outer_block.

    -
    outer_block: {
    +
    outer_block: {
       inner_block: {
         console.log('1');
         break outer_block; // breaks out of both inner_block and outer_block
    @@ -58,7 +58,7 @@ translation_of: Web/JavaScript/Reference/Statements/break
     
     

    The following code also uses break statements with labeled blocks but generates a Syntax Error because its break statement is within block_1 but references block_2. A break statement must always be nested within any label it references.

    -
    block_1: {
    +
    block_1: {
       console.log('1');
       break block_2; // SyntaxError: label not found
     }
    diff --git a/files/zh-tw/web/javascript/reference/statements/debugger/index.html b/files/zh-tw/web/javascript/reference/statements/debugger/index.html
    index 79a65a398e..d5d1662cf4 100644
    --- a/files/zh-tw/web/javascript/reference/statements/debugger/index.html
    +++ b/files/zh-tw/web/javascript/reference/statements/debugger/index.html
    @@ -22,7 +22,7 @@ translation_of: Web/JavaScript/Reference/Statements/debugger
     
     

    呼叫除錯器時,程式會在 debugger 宣告處暫停執行。它有點像是程式碼的斷點。

    -

    Paused at a debugger statement.

    +

    Paused at a debugger statement.

    規範

    diff --git a/files/zh-tw/web/javascript/reference/statements/for...in/index.html b/files/zh-tw/web/javascript/reference/statements/for...in/index.html index 92ab3aa5c0..727397cce0 100644 --- a/files/zh-tw/web/javascript/reference/statements/for...in/index.html +++ b/files/zh-tw/web/javascript/reference/statements/for...in/index.html @@ -47,12 +47,12 @@ translation_of: Web/JavaScript/Reference/Statements/for...in

    A for...in loop iterates over the properties of an object in an arbitrary order (see the delete operator for more on why one cannot depend on the seeming orderliness of iteration, at least in a cross-browser setting). If a property is modified in one iteration and then visited at a later time, its value in the loop is its value at that later time. A property that is deleted before it has been visited will not be visited later. Properties added to the object over which iteration is occurring may either be visited or omitted from iteration. In general it is best not to add, modify or remove properties from the object during iteration, other than the property currently being visited. There is no guarantee whether or not an added property will be visited, whether a modified property (other than the current one) will be visited before or after it is modified, or whether a deleted property will be visited before it is deleted.

    -
    -

    If you only want to consider properties attached to the object itself, and not its prototypes, use getOwnPropertyNames or perform a hasOwnProperty check (propertyIsEnumerable can also be used). Alternatively, if you know there won't be any outside code interference, you can extend built-in prototypes with a check method.

    +
    +

    Note: If you only want to consider properties attached to the object itself, and not its prototypes, use getOwnPropertyNames or perform a hasOwnProperty check (propertyIsEnumerable can also be used). Alternatively, if you know there won't be any outside code interference, you can extend built-in prototypes with a check method.

    -
    -

    for..in 不應該用來迭代一個索引順序很重要的陣列 陣列索引只是以整數命名的可列舉屬性,其他方面等同於一般物件屬性。 無法擔保 for...in 以特定順序傳回索引,並且它將傳回全部可列舉屬性,包括非整數名的,以及繼承而來的可列舉屬性。

    +
    +

    備註:for..in 不應該用來迭代一個索引順序很重要的陣列 陣列索引只是以整數命名的可列舉屬性,其他方面等同於一般物件屬性。 無法擔保 for...in 以特定順序傳回索引,並且它將傳回全部可列舉屬性,包括非整數名的,以及繼承而來的可列舉屬性。

    因為迭代的順序依賴於 JavaScript 引擎的實作,在不同引擎下,迭代一個陣列可能不是以一個一致的順序存取陣列元素。因此,當你迭代陣列,且該陣列的存取順序很重要時,最好是使用以數值索引的 for 迴圈 (或 Array.forEach 或非標準 for...of 迴圈)。

    diff --git a/files/zh-tw/web/javascript/reference/statements/label/index.html b/files/zh-tw/web/javascript/reference/statements/label/index.html index b8ba54d920..b67148b359 100644 --- a/files/zh-tw/web/javascript/reference/statements/label/index.html +++ b/files/zh-tw/web/javascript/reference/statements/label/index.html @@ -15,8 +15,8 @@ translation_of: Web/JavaScript/Reference/Statements/label -
    -

    標記的迴圈或程式碼區塊非常罕見。通常可以使用函式呼叫而不是使用迴圈跳轉。

    +
    +

    備註:標記的迴圈或程式碼區塊非常罕見。通常可以使用函式呼叫而不是使用迴圈跳轉。

    語法

    diff --git a/files/zh-tw/web/javascript/reference/statements/let/index.html b/files/zh-tw/web/javascript/reference/statements/let/index.html index f3170bb603..7c0b50b552 100644 --- a/files/zh-tw/web/javascript/reference/statements/let/index.html +++ b/files/zh-tw/web/javascript/reference/statements/let/index.html @@ -165,8 +165,8 @@ let i = 10;

    Another example of temporal dead zone combined with lexical scoping

    -

    Due to lexical scoping, the identifier "foo" inside the expression (foo + 55) evaluates to the if block's foo, and not the overlying variable foo with the value of 33.
    - In that very line, the if block's "foo" has already been created in the lexical environment, but has not yet reached (and terminated) its initialization (which is part of the statement itself): it's still in the temporal dead zone.

    +

    Due to lexical scoping, the identifier "foo" inside the expression (foo + 55) evaluates to the if block's foo, and not the overlying variable foo with the value of 33.
    + In that very line, the if block's "foo" has already been created in the lexical environment, but has not yet reached (and terminated) its initialization (which is part of the statement itself): it's still in the temporal dead zone.

    function test(){
        var foo = 33;
    @@ -176,7 +176,7 @@ let i = 10;
    } test();
    -

    This phenomenon may confuse you in a situation like the following. The instruction let n of n.a is already inside the private scope of the for loop's block, hence the identifier "n.a" is resolved to the property 'a' of the 'n' object located in the first part of the instruction itself ("let n"), which is still in the temporal dead zone since its declaration statement has not been reached and terminated.

    +

    This phenomenon may confuse you in a situation like the following. The instruction let n of n.a is already inside the private scope of the for loop's block, hence the identifier "n.a" is resolved to the property 'a' of the 'n' object located in the first part of the instruction itself ("let n"), which is still in the temporal dead zone since its declaration statement has not been reached and terminated.

    function go(n) {
       // n here is defined!
    diff --git a/files/zh-tw/web/javascript/reference/statements/return/index.html b/files/zh-tw/web/javascript/reference/statements/return/index.html
    index e207c2c6f3..be8cb4c346 100644
    --- a/files/zh-tw/web/javascript/reference/statements/return/index.html
    +++ b/files/zh-tw/web/javascript/reference/statements/return/index.html
    @@ -58,7 +58,7 @@ a + b;
     
     

    主控台會警告「unreachable code after return statement」(在 return 宣告後面有無法抵達的程式碼)。

    -
    從 Gecko 40 {{geckoRelease(40)}} 開始,如果主控台發現在 return 宣告後面有無法抵達的程式碼,就會顯示警告。
    +

    備註:從 Gecko 40 {{geckoRelease(40)}} 開始,如果主控台發現在 return 宣告後面有無法抵達的程式碼,就會顯示警告。

    要避免 ASI 問題,可以添加括號:

    diff --git a/files/zh-tw/web/javascript/reference/statements/throw/index.html b/files/zh-tw/web/javascript/reference/statements/throw/index.html index 9994f8c58c..82ba6282da 100644 --- a/files/zh-tw/web/javascript/reference/statements/throw/index.html +++ b/files/zh-tw/web/javascript/reference/statements/throw/index.html @@ -145,87 +145,11 @@ e = verifyZipCode('95060 1234'); // returns 95060 1234

    規範

    -
    陳述句陳述句
    Implemented in
    - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES3')}}{{Spec2('ES3')}}Initial definition. Implemented in JavaScript 1.4
    {{SpecName('ES5.1', '#sec-12.13', 'throw statement')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-throw-statement', 'throw statement')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-throw-statement', 'throw statement')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/statements/var/index.html b/files/zh-tw/web/javascript/reference/statements/var/index.html index 2ef07a3afa..c3a4712301 100644 --- a/files/zh-tw/web/javascript/reference/statements/var/index.html +++ b/files/zh-tw/web/javascript/reference/statements/var/index.html @@ -155,87 +155,11 @@ console.log(typeof y); // undefined as y is local to function a

    規範

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('ES1')}}{{Spec2('ES1')}}Initial definition. Implemented in JavaScript 1.0
    {{SpecName('ES5.1', '#sec-12.2', 'var statement')}}{{Spec2('ES5.1')}} 
    {{SpecName('ES6', '#sec-variable-statement', 'variable statement')}}{{Spec2('ES6')}} 
    {{SpecName('ESDraft', '#sec-variable-statement', 'variable statement')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatVersionUnknown}}
    -
    +{{Compat}}

    參見

    diff --git a/files/zh-tw/web/javascript/reference/strict_mode/index.html b/files/zh-tw/web/javascript/reference/strict_mode/index.html index b37e56f1ca..a6ebcd9b70 100644 --- a/files/zh-tw/web/javascript/reference/strict_mode/index.html +++ b/files/zh-tw/web/javascript/reference/strict_mode/index.html @@ -17,8 +17,8 @@ translation_of: Web/JavaScript/Reference/Strict_mode

    參考 過渡到嚴格模式,如果你希望將你的程式碼在  JavaScript 語法嚴格、語法受限下執行。

    -
    -

    Sometimes, you'll see the default, non-strict, mode referred to as "sloppy mode". This isn't an official term, but be aware of it, just in case.

    +
    +

    Note: Sometimes, you'll see the default, non-strict, mode referred to as "sloppy mode". This isn't an official term, but be aware of it, just in case.

    用法

    @@ -98,8 +98,8 @@ delete Object.prototype; // throws a TypeError

    Fourth, strict mode prior to Gecko 34 requires that all properties named in an object literal be unique. Normal code may duplicate property names, with the last one determining the property's value. But since only the last one does anything, the duplication is simply a vector for bugs, if the code is modified to change the property value other than by changing the last instance. Duplicate property names are a syntax error in strict mode:

    -
    -

    This is no longer the case in ECMAScript 2015 ({{bug(1041128)}}).

    +
    +

    Note: This is no longer the case in ECMAScript 2015 ({{bug(1041128)}}).

    'use strict';
    diff --git a/files/zh-tw/web/javascript/typed_arrays/index.html b/files/zh-tw/web/javascript/typed_arrays/index.html
    index 688dab7188..7213f515e1 100644
    --- a/files/zh-tw/web/javascript/typed_arrays/index.html
    +++ b/files/zh-tw/web/javascript/typed_arrays/index.html
    @@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Typed_arrays
     
     

    為了追求最大的可朔性與效率,JavaScript 型別陣列的實作分為緩衝視圖。一個緩衝(以類別 {{jsxref("ArrayBuffer")}} 實作)為代表一塊資料資料的物件,它沒有任何格式,也沒有任何存取其內容的機制。想存取一個緩衝所佔的記憶體必須用一個視圖。一個視圖提供了一種前後關係 — 資料型別、起始偏移與元素的數目 — 使得資料變成真實的型別陣列。視圖以類別 {{jsxref("ArrayBufferView")}} 與其子類別實作。

    -

    Typed arrays in an ArrayBuffer

    +

    Typed arrays in an ArrayBuffer

    ArrayBuffer

    @@ -125,7 +125,7 @@ var amountDueView = new Float32Array(buffer, 20, 1);

    舉例來說,可以用 amountDueView[0] 存取 amountDue。

    -
    備註:C 結構的 data structure alignment 是與使用平台有關,須小心這些填充上的差異。
    +

    備註:C 結構的 data structure alignment 是與使用平台有關,須小心這些填充上的差異。

    Conversion to normal arrays

    @@ -139,82 +139,11 @@ normalArray.constructor === Array;

    規範

    - - - - - - - - - - - - - - - - - - - - - - - -
    SpecificationStatusComment
    {{SpecName('Typed Array')}}{{Spec2('Typed Array')}}Superseded by ECMAScript 2015.
    {{SpecName('ES2015', '#sec-typedarray-objects', 'TypedArray Objects')}}{{Spec2('ES2015')}}Initial definition in an ECMA standard.
    {{SpecName('ESDraft', '#sec-typedarray-objects', 'TypedArray Objects')}}{{Spec2('ESDraft')}} 
    +{{Specifications}}

    瀏覽器相容性

    -

    {{CompatibilityTable}}

    - -
    - - - - - - - - - - - - - - - - - - - -
    FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari
    Basic support7.0{{ CompatGeckoDesktop("2") }}1011.65.1
    -
    - -
    - - - - - - - - - - - - - - - - - - - - - -
    FeatureAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
    Basic support4.0{{CompatVersionUnknown}}{{ CompatGeckoMobile("2") }}1011.64.2
    -
    +{{Compat}}

    參見

    -- cgit v1.2.3-54-g00ecf