I am trying to define an AsyncFunction (please note the big F) in node as described here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction
But I get:
AsyncFunction('var1', 'var2', 'let test=var1+var2') (1, 2)
ReferenceError: AsyncFunction is not defined
Creating a normal Function object works fine. Does NodeJS not support AsyncFunction?
I think the question you're fundamentally asking is what is the syntax for defining an asynchronous function, and not really trying to invoke the constructor of that object.
if so then:
synchronous:
function foo()
asynchronous:
async function bar()
Update: After understanding your comments, I encourage you to re-read the spec: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction
It clearly describes that it is not a global-scope object. The examples listed below it as well, also describe it's usage which also reinforce the idea that it must be assigned (locally) before usage, so there is a definition of it.