January 2020
Intermediate to advanced
470 pages
11h 13m
English
There is, however, a common (though in fact, harmless) mistake that is usually made. You often see code like this:
fetch("some/remote/url").then(function(data) { processResult(data);});
What does this code do? The idea is that a remote URL is fetched, and when the data arrives, a function is called—and this function itself calls processResult with data as an argument. That is to say, in the then() part, we want a function that, given data, calculates processResult(data). But don't we already have such a function?