Please note, this is a STATIC archive of website developer.mozilla.org from November 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Function.prototype.isGenerator()

非標準
This feature is non-standard and is not on a standards track. Do not use it on production sites facing the Web: it will not work for every user. There may also be large incompatibilities between implementations and the behavior may change in the future.

概要

関数がジェネレータであるか否かを示す真偽値を取得します。

構文

fun.isGenerator()

引数

無し

説明

このメソッドを使用すると、関数がジェネレータであるかどうかを調べる事ができます。

例

function f () { }

function g () {
  yield 42; // ※ yield が用いられている
}

console.log( "f.isGenerator() = " + f.isGenerator() );
console.log( "g.isGenerator() = " + g.isGenerator() );

このコードの出力は、以下の様になります。

f.isGenerator() = false
g.isGenerator() = true 

関連情報

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

 このページの貢献者: teoli, ethertank
 最終更新者: teoli,