★ wanayoo — archive 1999 https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/StopIterationNouvelle recherche | Portail wanayoo
mozilla
Your Search Results

    StopIteration

    This article is in need of an editorial review.

    This translation is incomplete. Please help translate this article from English.

    非標準。 StopIteration オブジェクトはSpiderMonkey特有の機能. 将来向きの用途に対して、for..of ループとiterator protocolを使用することを検討してください。

    概要

    StopIteration オブジェクトはレガシーイテレータプロトコルにおける反復の終了を通知するために使用します。

    構文

    StopIteration

    説明

    使用法の概要は、Iterators and Generators ページ上で利用可能です

    例

    StopIterationはIteratorによってスローされます。

    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
    

    StopIterationをスローする。

    function f() {
      yield 1;
      yield 2;
      throw StopIteration;
      yield 3; // this is not executed.
    }
    
    for (var n in f()) {
      console.log(n);   // 1
                        // 2
    }
    

    仕様

    非標準。すべての現在の標準仕様でサポートされていません。

    関連情報

    ドキュメントのタグと貢献者

    Contributors to this page: shide55
    最終更新者: shide55,
    サイドバーを隠す