3 ms·
I have to agree with the author here. In the promises example and the callback example, you end up declaring three functions. When you break all the callbacks i
by xlm1717 11y ago
I have to agree with the author here. In the promises example and the callback example, you end up declaring three functions. When you break all the callbacks into the same scope like the author did in the callback example, you end up with the same level of nesting as you would have had when you use promises.
You can also name your functions so you can have a better idea right away what that piece of code would do without having to follow the call chain, and then just pass the function name as the callback. You could use function names with promises too, but at that point why not dump that extra boilerplate code and use callbacks?