4 ms·
[removed]
by thatguyagain 7y ago
[removed]
- jhanschoo 7y agoNothing. It's just that you can have const result = await someFetchOrSomething(str); return result.foo; while not inside an async function. You still can't use it in a non-async function.
- efdee 7y agoYou can't return when you're not in a function ;-)
- efdee 7y agoNothing would change here. Normally, await can only appear in a method that has been marked as async. However, when you write toplevel code (code that's not wrapped in a function), you can't mark the function as async (because there is no function) so you can't use await. Enabling toplevel await fixes that.