diff options
author | t7yang <t7yang@gmail.com> | 2022-01-10 08:38:08 +0800 |
---|---|---|
committer | Irvin <irvinfly@gmail.com> | 2022-02-16 02:35:54 +0800 |
commit | f45e9e070c93ebbd83d488bdd775987a4d75c201 (patch) | |
tree | aacef5edaf768a188cadc46860f5b6aaa74f39ef /files/zh-tw/web/javascript/reference/global_objects/function | |
parent | 8ccfa93045a6c119303566370999f59a0aae3b25 (diff) | |
download | translated-content-f45e9e070c93ebbd83d488bdd775987a4d75c201.tar.gz translated-content-f45e9e070c93ebbd83d488bdd775987a4d75c201.tar.bz2 translated-content-f45e9e070c93ebbd83d488bdd775987a4d75c201.zip |
fix yari h2m dry run errors
Diffstat (limited to 'files/zh-tw/web/javascript/reference/global_objects/function')
5 files changed, 29 insertions, 356 deletions
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 <p><code><strong>apply() </strong>方法會呼叫一個以 this 的代表值和一個陣列形式的值組(或是一個 </code><a href="/en-US/docs/Web/JavaScript/Guide/Indexed_collections#Working_with_array-like_objects">array-like object</a> <code>)為參數的函式。</code></p> -<div class="note"> -<p><strong>注意:</strong>這個函式的語法和{{jsxref("Function.call", "call()")}} 幾乎一樣,最大的不同是 <code>call()</code> 接受<code><strong>一連串的參數</strong></code>,而 <code>apply() 接受<strong>一組陣列形式的參數</strong>。</code></p> +<div class="notecard note"> +<p><strong>備註:</strong>這個函式的語法和{{jsxref("Function.call", "call()")}} 幾乎一樣,最大的不同是 <code>call()</code> 接受<code><strong>一連串的參數</strong></code>,而 <code>apply() 接受<strong>一組陣列形式的參數</strong>。</code></p> </div> <h2 id="語法">語法</h2> @@ -38,8 +38,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply <p>從 ECMAScript 5th 版本後,也可以使用陣列形式的物件,在實踐上這代表他會擁有 <code>length 以及整數範圍 </code> <code>(0...length-1) 的屬性。舉例來說,你可以使用 </code>{{domxref("NodeList")}} 或是一個像這樣的自定義屬性: <code>{ 'length': 2, '0': 'eat', '1': 'bananas' }。</code></p> -<div class="note"> -<p>一般瀏覽器,包括 Chrome 14 及 Internet Explorer 9,仍不支援陣列形式的物件,所以會對此丟出一個錯誤。</p> +<div class="notecard note"> +<p><strong>備註:</strong>一般瀏覽器,包括 Chrome 14 及 Internet Explorer 9,仍不支援陣列形式的物件,所以會對此丟出一個錯誤。</p> </div> <h2 id="範例">範例</h2> @@ -55,8 +55,8 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Function/apply }; </pre> -<div class="note"> -<p><strong>注意:</strong>如上範例的 <code>Object.create()</code> 方法是屬於比較新的寫法。如需使用閉包的替代方法,請參考以下的範例:</p> +<div class="notecard note"> +<p><strong>備註:</strong>如上範例的 <code>Object.create()</code> 方法是屬於比較新的寫法。如需使用閉包的替代方法,請參考以下的範例:</p> <pre class="brush: js">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' </pre> -<div class="note"> -<p><strong>注意:</strong>This non-native <code>Function.construct</code> 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: <code>[2012, 11, 4]</code>; in this case you have to write something like: <code>new (Function.prototype.bind.apply(Date, [null].concat([2012, 11, 4])))()</code> — anyhow this is not the best way to do things and probably should not be used in any production environment).</p> +<div class="notecard note"> +<p><strong>備註:</strong>This non-native <code>Function.construct</code> 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: <code>[2012, 11, 4]</code>; in this case you have to write something like: <code>new (Function.prototype.bind.apply(Date, [null].concat([2012, 11, 4])))()</code> — anyhow this is not the best way to do things and probably should not be used in any production environment).</p> </div> <h3 id="使用_apply_於內建的函數">使用 <code>apply</code> 於內建的函數</h3> @@ -150,104 +150,11 @@ someobject.foo = function() { <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('ES3')}}</td> - <td>{{Spec2('ES3')}}</td> - <td>Initial definition. Implemented in JavaScript 1.3.</td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-15.3.4.3', 'Function.prototype.apply')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-function.prototype.apply', 'Function.prototype.apply')}}</td> - <td>{{Spec2('ES6')}}</td> - <td></td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-function.prototype.apply', 'Function.prototype.apply')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td></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>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - <tr> - <td>ES 5.1 generic array-like object as {{jsxref("Functions/arguments", "arguments")}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("2.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</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> - <tr> - <td>ES 5.1 generic array-like object as {{jsxref("Functions/arguments", "arguments")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile("2.0")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="參見">參見</h2> 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(); <h3 id="Bound_functions_used_as_constructors">Bound functions used as constructors</h3> -<div class="warning"> +<div class="notecard warning"> <p><strong>Warning:</strong> This section demonstrates JavaScript capabilities and documents some edge cases of the <code>bind()</code> method. The methods shown below are not the best way to do things and probably should not be used in any production environment.</p> </div> @@ -231,86 +231,11 @@ slice(arguments); <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('ES5.1', '#sec-15.3.4.5', 'Function.prototype.bind')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td>Initial definition. Implemented in JavaScript 1.8.5.</td> - </tr> - <tr> - <td>{{SpecName('ES2015', '#sec-function.prototype.bind', 'Function.prototype.bind')}}</td> - <td>{{Spec2('ES2015')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-function.prototype.bind', 'Function.prototype.bind')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </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("7")}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoDesktop("2")}}</td> - <td>{{CompatIE("9")}}</td> - <td>{{CompatOpera("11.60")}}</td> - <td>{{CompatSafari("5.1")}}</td> - </tr> - </tbody> -</table> -</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>Feature</th> - <th>Android</th> - <th>Chrome for Android</th> - <th>Edge</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>{{CompatAndroid("4.0")}}</td> - <td>{{CompatChrome("1")}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatGeckoMobile("2")}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatOperaMobile("11.5")}}</td> - <td>{{CompatSafari("6.0")}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="相關連結">相關連結</h2> 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 <p>使用給定的<code>this</code>參數以及分別給定的參數來呼叫某個函數</p> -<div class="note"><strong>附註:</strong> 此函數的所有語法大致上與<code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/apply">apply()</a></code>相同,他們基本上不同處只有 <code>call()</code> 接受一連串的參數,而 <code>apply()</code> 單一的array作為參數</div> +<div class="notecard note"> + <p><strong>備註:</strong> 此函數的所有語法大致上與<code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Function/apply" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/apply">apply()</a></code>相同,他們基本上不同處只有 <code>call()</code> 接受一連串的參數,而 <code>apply()</code> 單一的array作為參數</p> +</div> <table class="standard-table"> <thead> <tr> - <th class="header" colspan="2"><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Function" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function">Function </a>物件的方法</th> + <th colspan="2"><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Function" title="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function">Function </a>物件的方法</th> </tr> </thead> <tbody> @@ -98,6 +100,14 @@ for (var i = 0; i < animals.length; i++) { } </pre> +<h2 id="規範">規範</h2> + +{{Specifications}} + +<h2 id="瀏覽器相容性">瀏覽器相容性</h2> + +{{Compat}} + <h2 id="參見">參見</h2> <ul> 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 <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. Implemented in JavaScript 1.0.</td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-15.3', 'Function')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-function-objects', 'Function')}}</td> - <td>{{Spec2('ES6')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-function-objects', 'Function')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </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>Opera</th> - <th>Safari</th> - </tr> - <tr> - <td>Basic support</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</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/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 */ <h2 id="規範">規範</h2> -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">規範</th> - <th scope="col">狀態</th> - <th scope="col">註釋</th> - </tr> - <tr> - <td>{{SpecName('ES1')}}</td> - <td>{{Spec2('ES1')}}</td> - <td>最初的定義,在 JavaScript 1.1 中實作。</td> - </tr> - <tr> - <td>{{SpecName('ES5.1', '#sec-15.3.5.1', 'Function.length')}}</td> - <td>{{Spec2('ES5.1')}}</td> - <td> </td> - </tr> - <tr> - <td>{{SpecName('ES6', '#sec-function-instances-length', 'Function.length')}}</td> - <td>{{Spec2('ES6')}}</td> - <td><code>此 </code>property 的 <code>configurable</code> attribute 現在為 <code>true</code>.</td> - </tr> - <tr> - <td>{{SpecName('ESDraft', '#sec-function-instances-length', 'Function.length')}}</td> - <td>{{Spec2('ESDraft')}}</td> - <td> </td> - </tr> - </tbody> -</table> +{{Specifications}} <h2 id="瀏覽器相容性">瀏覽器相容性</h2> -<div>{{CompatibilityTable}}</div> - -<div> -<table class="compat-table"> - <tbody> - <tr> - <th>特點</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>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - <td>{{CompatVersionUnknown}}</td> - </tr> - <tr> - <td>Configurable: true</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoDesktop(37)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</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> - <tr> - <td>Configurable: true</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatGeckoMobile(37)}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - <td>{{CompatUnknown}}</td> - </tr> - </tbody> -</table> -</div> +{{Compat}} <h2 id="可參閱">可參閱</h2> |