Should the following code work?
if(true) {
async function bar() {
console.log("hello");
}
}
bar();
Chrome 80 and Firefox 72 both throw a ReferenceError
saying bar
is not defined. So it seems like async function bar() {...}
declarations are block scoped whereas function bar() {...}
declarations are function scoped? Confusing if that's the case, but can someone just confirm that for me with a link to the relevant part of the spec?
Also, is there a way to make an async function
declaration function-scoped when declared from within a block?