非标准
该特性是非标准的,请尽量不要在生产环境中使用它!
判断一个函数是否是一个生成器.
fun.isGenerator()
该方法用来判断一个函数是否是一个生成器.
function f() {}
function* g() {
yield 42;
}
console.log("f.isGenerator() = " + f.isGenerator());
console.log("g.isGenerator() = " + g.isGenerator());
上面代码的输出结果为
f.isGenerator() = false g.isGenerator() = true