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:
const AsyncFunction = async function () {}.constructor;
AsyncFunction
是 Function
的子类。
¥AsyncFunction
is a subclass of Function
.
构造函数
实例属性
¥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[Symbol.toStringTag]
-
[Symbol.toStringTag]
属性的初始值为字符串"AsyncFunction"
。该属性在Object.prototype.toString()
中使用。
注意:
AsyncFunction
实例没有prototype
属性。¥Note:
AsyncFunction
instances do not have theprototype
property.
实例方法
规范
Specification |
---|
ECMAScript Language Specification # sec-async-function-objects |
浏览器兼容性
BCD tables only load in the browser