diff options
Diffstat (limited to 'files/zh-tw/web/javascript/reference/operators')
10 files changed, 28 insertions, 338 deletions
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();</pre> <h2 id="規範">規範</h2> -<table class="standard-table"> - <thead> - <tr> - <th scope="col">規範</th> - <th scope="col">狀態</th> - <th scope="col">註解</th> - </tr> - </thead> - <tbody> - <tr> - <td>{{SpecName('ESDraft', '#sec-async-function-definitions', 'async functions')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td>ES2017中初始定義</td> - </tr> - </tbody> -</table> +{{Specifications}} <h2 id="瀏覽器相容性">瀏覽器相容性</h2> -<div>{{CompatibilityTable}}</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Edge</th> - <th>Opera</th> - <th>Safari (WebKit)</th> - </tr> - <tr> - <td>基本支援</td> - <td>{{CompatChrome(55)}}</td> - <td>{{CompatGeckoDesktop("52.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(42)}}</td> - <td>10.1</td> - </tr> - </tbody> -</table> -</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Android Webview</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>基本支援</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatGeckoMobile("52.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOpera(42)}}</td> - <td>10.1</td> - <td>{{CompatChrome(55)}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="See_also">See also</h2> 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 <p>The following code prints the values of the diagonal elements in the array:</p> -<pre class="brush:js;highlight:[1]">for (var i = 0, j = 9; i <= 9; i++, j--) +<pre class="brush:js">for (var i = 0, j = 9; i <= 9; i++, j--) console.log("a[" + i + "][" + j + "] = " + a[i][j]);</pre> <p>Note that the comma in assignments such as the <code>var</code> statement may appear not to have the normal effect of comma operators because they don't exist within an expression. In the following example, <code>a</code> is set to the value of <code>b = 3</code> (which is 3), but the <code>c = 4</code> expression still evaluates and its result returned to console (i.e., 4). This is due to <a href="/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence">operator precedence and associativity</a>.</p> @@ -56,87 +56,11 @@ console.log(x); // 6 (right-most) <h2 id="規範">規範</h2> -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-comma-operator', 'Comma operator')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-comma-operator', 'Comma operator')}}</td> - <td>{{Spec2('ES6')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-11.14', 'Comma operator')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ES1', '#sec-11.14', 'Comma operator')}}</td> - <td>{{Spec2('ES1')}}</td> - <td>Initial definition</td> - </tr> - </tbody> -</table> +{{Specifications}} <h2 id="瀏覽器相容性">瀏覽器相容性</h2> -<p>{{CompatibilityTable}}</p> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>3.0</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> -</table> -</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="參見">參見</h2> 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});</pre> -<div class="note"> -<p><strong>注意</strong>:當針對物件進行解構,而該句式沒有進行宣告時,指派式外必須加上括號 <code>( ... )</code> 。</p> +<div class="notecard note"> +<p><strong>備註:</strong>當針對物件進行解構,而該句式沒有進行宣告時,指派式外必須加上括號 <code>( ... )</code> 。</p> <p><code>{a, b} = {a: 1, b: 2}</code> 不是有效的獨立語法,因為左邊的 <code>{a, b}</code> 被視為程式碼區塊而非物件。</p> @@ -277,8 +277,8 @@ drawChart({ radius: 30 });</pre> -<div class="note"> -<p>在上述函式 <strong><code>drawChart</code></strong> 中,左方之解構式被指派到一個空物件: <code>{size = 'big', coords = {x: 0, y: 0}, radius = 25} = {}</code> 。你也可以略過填寫右方的指派式。不過,當你沒有使用右方指派式時,函式在呼叫時會找出最少一個參數。透過上述形式,你可以直接不使用參數的呼叫 <code><strong>drawChart()</strong></code> 。當你希望在呼叫這個函式時不傳送參數,這個設計會帶來方便。而另一個設計則能讓你確保函式必須傳上一個物件作為參數。</p> +<div class="notecard note"> +<p><strong>備註:</strong>在上述函式 <strong><code>drawChart</code></strong> 中,左方之解構式被指派到一個空物件: <code>{size = 'big', coords = {x: 0, y: 0}, radius = 25} = {}</code> 。你也可以略過填寫右方的指派式。不過,當你沒有使用右方指派式時,函式在呼叫時會找出最少一個參數。透過上述形式,你可以直接不使用參數的呼叫 <code><strong>drawChart()</strong></code> 。當你希望在呼叫這個函式時不傳送參數,這個設計會帶來方便。而另一個設計則能讓你確保函式必須傳上一個物件作為參數。</p> </div> <h3 id="巢狀物件或陣列的解構">巢狀物件或陣列的解構</h3> 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 <dd>大於等於運算子。</dd> </dl> -<div class="note"> -<p><strong>Note: =></strong> is not an operator, but the notation for <a href="/zh-TW/docs/Web/JavaScript/Reference/Functions/Arrow_functions">Arrow functions</a>.</p> +<div class="notecard note"> +<p><strong>Note:</strong> => is not an operator, but the notation for <a href="/zh-TW/docs/Web/JavaScript/Reference/Functions/Arrow_functions">Arrow functions</a>.</p> </div> <h3 id="相等運算子">相等運算子</h3> 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); <h2 id="規範">規範</h2> -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Specification</th> - <th scope="col">Status</th> - <th scope="col">Comment</th> - </tr> - <tr> - <td>{{SpecName('ES1')}}</td> - <td>{{Spec2('ES1')}}</td> - <td>initial definition.</td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-11.1.5', 'Object Initializer')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td><a href="/en-US/docs/Web/JavaScript/Reference/Functions/get">getter</a> and <a href="/en-US/docs/Web/JavaScript/Reference/Functions/set">setter</a> added.</td> - </tr> - <tr> - <td>{{SpecName('ES2015', '#sec-object-initializer', 'Object Initializer')}}</td> - <td>{{Spec2('ES2015')}}</td> - <td>Shorthand method/property names and computed property names added.</td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-object-initializer', 'Object Initializer')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </td> - </tr> - <tr> - <td><a href="https://github.com/tc39/proposal-object-rest-spread">Rest/Spread Properties for ECMAScript </a></td> - <td>Draft</td> - <td>Stage 3 draft.</td> - </tr> - </tbody> -</table> +{{Specifications}} <h2 id="瀏覽器相容性">瀏覽器相容性</h2> -<div>{{CompatibilityTable}}</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Chrome</th> - <th>Edge</th> - <th>Firefox (Gecko)</th> - <th>Internet Explorer</th> - <th>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatChrome(1.0)}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("1.0")}}</td> - <td>1</td> - <td>1</td> - <td>1</td> - </tr> - <tr> - <td>Computed property names</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("34")}}</td> - <td>{{CompatNo}}</td> - <td>34</td> - <td>7.1</td> - </tr> - <tr> - <td>Shorthand property names</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("33")}}</td> - <td>{{CompatNo}}</td> - <td>34</td> - <td>9</td> - </tr> - <tr> - <td>Shorthand method names</td> - <td>{{CompatChrome(42.0)}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("34")}}</td> - <td>{{CompatNo}}</td> - <td>34</td> - <td>9</td> - </tr> - <tr> - <td>Spread properties</td> - <td>{{CompatChrome(60)}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatGeckoDesktop("55")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Android Webview</th> - <th>Edge</th> - <th>Firefox Mobile (Gecko)</th> - <th>IE Mobile</th> - <th>Opera Mobile</th> - <th>Safari Mobile</th> - <th>Chrome for Android</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile("1.0")}}</td> - <td>1</td> - <td>1</td> - <td>1</td> - <td>{{CompatChrome(1.0)}}</td> - </tr> - <tr> - <td>Computed property names</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile("34")}}</td> - <td>{{CompatNo}}</td> - <td>34</td> - <td>7.1</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td>Shorthand property names</td> - <td>{{CompatNo}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile("33")}}</td> - <td>{{CompatNo}}</td> - <td>34</td> - <td>9</td> - <td>{{CompatNo}}</td> - </tr> - <tr> - <td>Shorthand method names</td> - <td>{{CompatNo}}</td> - <td>{{CompatChrome(42.0)}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile("34")}}</td> - <td>{{CompatNo}}</td> - <td>34</td> - <td>9</td> - <td>{{CompatChrome(42.0)}}</td> - </tr> - <tr> - <td>Spread properties</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatGeckoMobile("55")}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - <td>{{CompatNo}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="參見">參見</h2> 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 <p>下方表格列出運算子的相依性,從高 (20) 到低 (1)。</p> -<table class="fullwidth-table"> +<table> <tbody> <tr> <th>優先性<br> 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 <pre class="brush: js">let result = someInterface.customMethod?.();</pre> -<div class="blockIndicator note"> -<p><strong>注意:</strong> 假如物件有同樣的屬性名稱,而不是一個方法,使用 <code>?.</code> 將會抛出 {{JSxRef("TypeError")}} 錯誤(<code>x.y</code><code> 不是一個函數</code>.</p> +<div class="notecard note"> +<p><strong>備註:</strong>假如物件有同樣的屬性名稱,而不是一個方法,使用 <code>?.</code> 將會抛出 {{JSxRef("TypeError")}} 錯誤(<code>x.y</code><code> 不是一個函數</code>.</p> </div> <h4 id="處理回呼函式或事件處理器">處理回呼函式或事件處理器</h4> 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 </pre> -<div class="blockIndicator note"> +<div class="notecard note"> <p><strong>Note:</strong> 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.)</p> <pre class="brush: js example-bad">const a = [[1], [2], [3]]; @@ -165,7 +165,7 @@ arr1 = [...arr2, ...arr1]; // arr1 is now [3, 4, 5, 0, 1, 2] </pre> -<div class="blockIndicator note"> +<div class="notecard note"> <p><strong>Note:</strong> Unlike <code>unshift()</code>, this creates a new <code>arr1</code>, and does not modify the original <code>arr1</code> array in-place.</p> </div> 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</pre> <p>所以在嚴格模式下,如果 <code>this</code> 沒有定義到執行環境內,其預設值就會是 <code>undefined</code>。</p> -<div class="note"> -<p>在第二個例子裡面,<code>this</code> 應為 <a href="/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/undefined"><code>undefined</code></a>,因為 <code>f2</code> 是直接被呼叫,而不是在其為某個物件的方法或屬性的情況下(例如 <code>window.f2()</code>)被直接呼叫。某些瀏覽器首次支援<a href="/zh-TW/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode" title="Strict mode">嚴格模式</a>時沒導入這個特徵,它們會因此錯誤的回傳 <code>window</code> 物件。</p> +<div class="notecard note"> +<p><strong>備註:</strong>在第二個例子裡面,<code>this</code> 應為 <a href="/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/undefined"><code>undefined</code></a>,因為 <code>f2</code> 是直接被呼叫,而不是在其為某個物件的方法或屬性的情況下(例如 <code>window.f2()</code>)被直接呼叫。某些瀏覽器首次支援<a href="/zh-TW/docs/Web/JavaScript/Reference/Functions_and_function_scope/Strict_mode" title="Strict mode">嚴格模式</a>時沒導入這個特徵,它們會因此錯誤的回傳 <code>window</code> 物件。</p> </div> <p>要從某個語境訪問另一個 <code>this</code> 語境的值,請使用 <a href="/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Function/call">call</a> 或 <a href="/zh-TW/docs/Web/JavaScript/Reference/Global_Objects/Function/apply">apply</a>:</p> @@ -138,8 +138,8 @@ console.log(o.f(), o.g(), o.h()); // 37, azerty, azerty</code> var foo = (() => this); console.log(foo() === globalObject); // true</pre> -<div class="note"> -<p>註:如果這參數被傳遞給箭頭函式的 call, bind, apply 調用,該參數會被忽略。你仍然可以將參數預先調用到call,但第一個參數(thisArg)必須設置為空。</p> +<div class="notecard note"> +<p><strong>備註:</strong>如果這參數被傳遞給箭頭函式的 call, bind, apply 調用,該參數會被忽略。你仍然可以將參數預先調用到call,但第一個參數(thisArg)必須設置為空。</p> </div> <pre class="brush: js">// 作為物件的方法呼叫 @@ -253,8 +253,8 @@ console.log(o.average, o.sum); // logs 2, 6 <p>若函式以建構子的身份呼叫(使用 <code><a href="/zh-TW/docs/Web/JavaScript/Reference/Operators/new">new</a></code> 關鍵字) <code>this</code> 會和被建構的新物件綁定。</p> -<div class="note"> -<p>建構子預設透過 <code>this</code> 回傳該物件的參照,但它其實能回傳其他物件。如果回傳值不是物件的話,就會回傳 <code>this</code> 這個物件。</p> +<div class="notecard note"> +<p><strong>備註:</strong>建構子預設透過 <code>this</code> 回傳該物件的參照,但它其實能回傳其他物件。如果回傳值不是物件的話,就會回傳 <code>this</code> 這個物件。</p> </div> <pre class="brush:js">/* 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'; <p>這個問題已計畫<a class="external" href="http://wiki.ecmascript.org/doku.php?id=harmony:typeof_null">在下一版 ECMAScript 予以修正</a> (會以 opt-in 方式提供). 屆時它將會做出如 <code>typeof null === 'null'</code> 的正確回傳結果。</p> -<div class="note"> -<p>註: 此修正計畫已被拒絕</p> +<div class="notecard note"> +<p><strong>備註:</strong>此修正計畫已被拒絕</p> </div> <h3 id="正規表示式_(Regular_expressions)">正規表示式 (Regular expressions)</h3> @@ -162,8 +162,8 @@ typeof /s/ === 'object'; // Firefox 5+ ... // 符合 ECMAScript 5.1 <p>在 IE 6, 7 和 8, <code>typeof alert === 'object'</code></p> -<div class="note"> -<p>註: 這並不怪異。這是實情。在許多較舊的 IE 中, 主機端物件的確是物件, 而非函數</p> +<div class="notecard note"> +<p><strong>備註:</strong>這並不怪異。這是實情。在許多較舊的 IE 中, 主機端物件的確是物件, 而非函數</p> </div> <h2 id="規格">規格</h2> |