JS: AsyncFunction object

By Xah Lee. Date: .
work in progress

What is AsyncFunction

AsyncFunction is the object returned when you define a async function

Async function constructor

AsyncFunction is not a global object. You cannot access it directly. It can be obtained by defining a async function and get its constructor property.

AsyncFunction.prototype.constructor

value is a object of type AsyncFunction. you cannot directly access except by this constructor property.

const cc = async function () {}.constructor;

console.log(cc);
// [Function: AsyncFunction]

console.assert(
 Reflect.apply(Object.prototype.toString, cc, []) ===
  "[object Function]",
);
AsyncFunction.prototype[Symbol.toStringTag]

value is "AsyncFunction"

async function xx() {}

console.assert(
 xx[Symbol.toStringTag] === "AsyncFunction",
);