3 ms·
> Cannot use higher order functions This code: async function renderChapters(urls) { urls.map(getJSON).forEach(j => (await j).html)); } is as
by edgyswingset 11y ago
> Cannot use higher order functions
This code:
async function renderChapters(urls) {
urls.map(getJSON).forEach(j => (await j).html));
}
is assuming that the call to await j is the await which corresponds to the top-level async. That's not how these things work! That call to await j is not in the same scope!
I don't buy arguments where the misuses of a feature not working means the feature is somehow bad. Yes, it can seem confusing, but that's the nature of having more powerful constructs. When you mix asynchronous code and lambda expressions, you're going to have to pay attention to scope.