AsyncGeneratorFunction
AsyncGeneratorFunction 对象为 异步生成器函数 提供方法。在 JavaScript 中,每个异步生成器函数实际上都是一个 AsyncGeneratorFunction 对象。
¥The AsyncGeneratorFunction object provides methods for async generator functions. In JavaScript, every async generator function is actually an AsyncGeneratorFunction object.
请注意,AsyncGeneratorFunction 不是全局对象。可以通过以下代码获取:
¥Note that AsyncGeneratorFunction is not a global object. It can be obtained with the following code:
const AsyncGeneratorFunction = async function* () {}.constructor;
AsyncGeneratorFunction 是 Function 的子类。
¥AsyncGeneratorFunction is a subclass of Function.
Try it
构造函数
实例属性
¥Instance properties
还从其父级 Function 继承实例属性。
¥Also inherits instance properties from its parent Function.
这些属性在 AsyncGeneratorFunction.prototype 上定义并由所有 AsyncGeneratorFunction 实例共享。
¥These properties are defined on AsyncGeneratorFunction.prototype and shared by all AsyncGeneratorFunction instances.
AsyncGeneratorFunction.prototype.constructor-
创建实例对象的构造函数。对于
AsyncGeneratorFunction实例,初始值为AsyncGeneratorFunction构造函数。 AsyncGeneratorFunction.prototype.prototype-
所有异步生成器函数共享相同的
prototype属性,即AsyncGenerator.prototype。使用async function*语法或AsyncGeneratorFunction()构造函数创建的每个异步生成器函数也有自己的prototype属性,其原型是AsyncGeneratorFunction.prototype.prototype。调用异步生成器函数时,其prototype属性将成为返回的异步生成器对象的原型。 AsyncGeneratorFunction.prototype[Symbol.toStringTag]-
[Symbol.toStringTag]属性的初始值为字符串"AsyncGeneratorFunction"。该属性在Object.prototype.toString()中使用。
这些属性是每个 AsyncGeneratorFunction 实例自己的属性。
¥These properties are own properties of each AsyncGeneratorFunction instance.
实例方法
规范
| Specification |
|---|
| ECMAScript Language Specification # sec-asyncgeneratorfunction-objects |
浏览器兼容性
BCD tables only load in the browser