aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/javascript/reference/global_objects/iterator/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/javascript/reference/global_objects/iterator/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/javascript/reference/global_objects/iterator/index.html')
-rw-r--r--files/ja/web/javascript/reference/global_objects/iterator/index.html95
1 files changed, 95 insertions, 0 deletions
diff --git a/files/ja/web/javascript/reference/global_objects/iterator/index.html b/files/ja/web/javascript/reference/global_objects/iterator/index.html
new file mode 100644
index 0000000000..3a641ff7d9
--- /dev/null
+++ b/files/ja/web/javascript/reference/global_objects/iterator/index.html
@@ -0,0 +1,95 @@
+---
+title: Iterator
+slug: Web/JavaScript/Reference/Global_Objects/Iterator
+tags:
+ - Deprecated
+ - JavaScript
+ - Legacy Iterator
+ - Reference
+translation_of: Archive/Web/Iterator
+---
+<div>{{jsSidebar("Objects")}}</div>
+
+<div class="warning"><strong>非標準。</strong> <code><strong>Iterator</strong></code> 関数は SpiderMonkey固有の機能で、ある時点で削除されます。将来向きの用途に対して、<a href="/docs/Web/JavaScript/Reference/Statements/for...of" title="/docs/Web/JavaScript/Reference/Statements/for...of">for..of</a>ループと<a href="/docs/Web/JavaScript/Guide/The_Iterator_protocol">iterator protocol</a>を使用することを検討してください。</div>
+
+<h2 id="概要">概要</h2>
+
+<p>レガシーイテレータプロトコルを実装し、オブジェクトの列挙可能なプロパティに対して反復するオブジェクトを返します。</p>
+
+<h2 id="構文">構文</h2>
+
+<pre class="syntaxbox">Iterator(<var>object</var>, [keyOnly])</pre>
+
+<h3 id="引数">引数</h3>
+
+<dl>
+ <dt><code>object</code></dt>
+ <dd>プロパティを反復処理するオブジェクト。</dd>
+ <dt><code>keyOnly</code></dt>
+ <dd><code>keyOnly</code> が truthy な値である場合は、<code>Iterator.prototype.next</code> が <code>property_name</code> のみ返します。</dd>
+</dl>
+
+<h2 id="説明">説明</h2>
+
+<p>使用方法の概要が<a href="/docs/JavaScript/Guide/Iterators_and_Generators" title="/docs/JavaScript/Guide/Iterators_and_Generators">Iterators and Generators</a>ページで提供されています。</p>
+
+<h2 id="メソッド">メソッド</h2>
+
+<dl>
+ <dt><code><strong>Iterator.prototype.next</strong></code></dt>
+ <dd><code>[property_name, property_value]</code>フォーマットで次のアイテムを返します。それ以上のアイテムが存在しない場合、<code><a href="/docs/Web/JavaScript/Reference/Global_Objects/StopIteration">StopIteration</a></code>をスローします。</dd>
+</dl>
+
+<h2 id="例">例</h2>
+
+<h3 id="オブジェクトのプロパティを反復処理する">オブジェクトのプロパティを反復処理する</h3>
+
+<pre class="brush: js">var a = {
+ x: 10,
+ y: 20,
+};
+var iter = Iterator(a);
+console.log(iter.next()); // ["x", 10]
+console.log(iter.next()); // ["y", 20]
+console.log(iter.next()); // throws StopIteration
+</pre>
+
+<h3 id="レガシーデストラクタfor-in文を使用してオブジェクトのプロパティを反復処理する">レガシーデストラクタ<code>for-in</code>文を使用してオブジェクトのプロパティを反復処理する</h3>
+
+<pre class="brush: js">var a = {
+ x: 10,
+ y: 20,
+};
+
+for (var [name, value] in Iterator(a)) {
+ console.log(name, value); // x 10
+ // y 20
+}
+</pre>
+
+<h3 id="for-ofとともにイテレータを使用する">for-ofとともにイテレータを使用する</h3>
+
+<pre class="brush: js">var a = {
+ x: 10,
+ y: 20,
+};
+
+for (var [name, value] of Iterator(a)) { // @@iterator is used
+ console.log(name, value); // x 10
+ // y 20
+}</pre>
+
+<h2 id="仕様">仕様</h2>
+
+<p>非標準。すべての現在の仕様書でサポートされていません。</p>
+
+<h2 id="ブラウザ実装状況">ブラウザ実装状況</h2>
+
+<p>サポートされていません。バージョン 57 より前の Firefox でサポートしていました。</p>
+
+<h2 id="関連情報">関連情報</h2>
+
+<ul>
+ <li><a href="/docs/JavaScript/Guide/Iterators_and_Generators" title="/en-US/docs/JavaScript/Guide/Iterators_and_Generators">Iterators and Generators</a></li>
+ <li><code><a href="/docs/Web/JavaScript/Reference/Global_Objects/StopIteration">StopIteration</a></code></li>
+</ul>