There is an article AsyncFunction - JavaScript on MDN. It shows the following snippet:
new AsyncFunction([arg1[, arg2[, ...argN]],] functionBody)
Yet in both Mozzila Firefox 55 and Google Chrome, this constructor is not defined at all:
I found out that (async function() {}).constructor
really is AsyncFunction
, but why can't I see it in global scope?
As mentioned in the Mozilla docs "Note that AsyncFunction is not a global object."
Therefore you can't access it as a property of the window
object like other global constructors. It must be obtained by interrogating an instance of an async
function:
From the docs:
const AsyncFunction = Object.getPrototypeOf(async function(){}).constructor;