diff options
Diffstat (limited to 'files/zh-tw/web/javascript/reference/statements/for...in/index.html')
-rw-r--r-- | files/zh-tw/web/javascript/reference/statements/for...in/index.html | 12 |
1 files changed, 6 insertions, 6 deletions
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 2c903faf2e..92ab3aa5c0 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 @@ -5,7 +5,7 @@ translation_of: Web/JavaScript/Reference/Statements/for...in --- <p>{{jsSidebar("Statements")}}</p> -<h2 id="Summary" name="Summary">Summary</h2> +<h2 id="Summary">Summary</h2> <p>迭代物件的可列舉屬性。對每個相異屬性,執行陳述式。</p> @@ -27,12 +27,12 @@ translation_of: Web/JavaScript/Reference/Statements/for...in </tbody> </table> -<h2 id="Syntax" name="Syntax">語法</h2> +<h2 id="Syntax">語法</h2> <pre class="syntaxbox">for (<var>變數</var> in <var>物件</var>) {<em>...</em> }</pre> -<h3 id="Parameters" name="Parameters">參數</h3> +<h3 id="Parameters">參數</h3> <dl> <dt><code>變數</code></dt> @@ -41,7 +41,7 @@ translation_of: Web/JavaScript/Reference/Statements/for...in <dd>Object whose enumerable properties are iterated.</dd> </dl> -<h2 id="Description" name="Description">Description</h2> +<h2 id="Description">Description</h2> <p><code>for...in</code> 迴圈只迭代可列舉屬性。由內建建構式(如:Array、Object) 製造的物件,從 <code>Object.prototype</code> 和 <code>String.prototype</code> 繼承了不可列舉屬性,如: <code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/String">String</a></code>的<code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/String/indexOf">indexOf</a></code> 方法,或 <code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object">Object</a></code>的 <code><a href="/en-US/docs/JavaScript/Reference/Global_Objects/Object/toString">toString</a></code> 方法。 迴圈將迭代全部可列舉屬性,包括了物件自身的和物件繼承自它的建構式之原型的可列舉屬性。(原型鏈上較接近物件的屬性覆蓋原型的屬性)</p> @@ -57,7 +57,7 @@ translation_of: Web/JavaScript/Reference/Statements/for...in <p>因為迭代的順序依賴於 JavaScript 引擎的實作,在不同引擎下,迭代一個陣列可能不是以一個一致的順序存取陣列元素。因此,當你迭代陣列,且該陣列的存取順序很重要時,最好是使用以數值索引的 <a href="/en-US/docs/JavaScript/Reference/Statements/for">for</a> 迴圈 (或 <a href="/en-US/docs/JavaScript/Reference/Global_Objects/Array/forEach">Array.forEach</a> 或非標準 <code><a href="/en-US/docs/JavaScript/Reference/Statements/for...of">for...of</a></code> 迴圈)。</p> </div> -<h2 id="Example" name="Example">Examples</h2> +<h2 id="Example">Examples</h2> <p>The following function takes as its arguments an object and the object's name. It then iterates over all the object's enumerable properties and returns a string of the property names and their values.</p> @@ -102,7 +102,7 @@ o = new ColoredTriangle(); alert(show_own_props(o, "o")); /* alerts: o.color = red */ </pre> -<h2 id="See_also" name="See_also">See also</h2> +<h2 id="See_also">See also</h2> <ul> <li><a href="/en-US/docs/JavaScript/Reference/Statements/for...of"><code>for...of</code></a> - a similar statement that iterates over the property <em>values</em></li> |