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 对象。

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

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

AsyncFunctionFunction 的子类。

构造函数

AsyncFunction()

创建一个新的 AsyncFunction 对象。

实例属性

同时也从它的父类 Function 继承实例属性

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

AsyncFunction.prototype.constructor

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

AsyncFunction.prototype[Symbol.toStringTag]

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

备注: AsyncFunction 实例并没有 prototype 属性。

实例方法

同时也从它的父类 Function 继承方法

规范

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

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
AsyncFunction
AsyncFunction() constructor

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见