AsyncFunction

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2017.

AsyncFunction 对象为 异步函数 提供方法。在 JavaScript 中,每个异步函数实际上都是一个 AsyncFunction 对象。

¥The AsyncFunction object provides methods for async functions. In JavaScript, every async function is actually an AsyncFunction object.

请注意,AsyncFunction 不是全局对象。可以通过以下代码获取:

¥Note that AsyncFunction is not a global object. It can be obtained with the following code:

js
const AsyncFunction = async function () {}.constructor;

AsyncFunctionFunction 的子类。

¥AsyncFunction is a subclass of Function.

构造函数

¥Constructor

AsyncFunction()

创建一个新的 AsyncFunction 对象。

实例属性

¥Instance properties

还从其父级 Function 继承实例属性。

¥Also inherits instance properties from its parent Function.

这些属性在 AsyncFunction.prototype 上定义并由所有 AsyncFunction 实例共享。

¥These properties are defined on AsyncFunction.prototype and shared by all AsyncFunction instances.

AsyncFunction.prototype.constructor

创建实例对象的构造函数。对于 AsyncFunction 实例,初始值为 AsyncFunction 构造函数。

AsyncFunction.prototype[@@toStringTag]

@@toStringTag 属性的初始值为字符串 "AsyncFunction"。该属性在 Object.prototype.toString() 中使用。

注意:AsyncFunction 实例没有 prototype 属性。

¥Note: AsyncFunction instances do not have the prototype property.

实例方法

¥Instance methods

从其父级 Function 继承实例方法。

¥Inherits instance methods from its parent Function.

规范

Specification
ECMAScript Language Specification
# sec-async-function-objects

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看