Not much, honestly. You're filling the local scope with a bunch of variable names of which you need to keep track. In a simple example, there's hardly any difference. In a complex one, I'd rather not have a bunch of variables there if I can avoid it.
I think that your article could be greatly improved if you used examples of clean code written using promises. As it is now, the proper conclusion to your article is "Well, you can only claim that because you're using bad examples of promises." Arguing for async/await is all good and that, but if you want to make the point that it's clearer than promises, at least use cleanly written code.
I really don't understand why you're wrapping everything in a Promise. Assuming that you're various getIngredient functions are asynchronous (which judging by your async/await examples they are), you don't need to write this:
Which has the advantage of not needing to store the stuff in a variable and return it, as the return will be immediately available in the following then statement.
And again, if you're going to claim that async/await is much cleaner than promises, at the very least don't use code like this:
Not much, honestly. You're filling the local scope with a bunch of variable names of which you need to keep track. In a simple example, there's hardly any difference. In a complex one, I'd rather not have a bunch of variables there if I can avoid it.
I think that your article could be greatly improved if you used examples of clean code written using promises. As it is now, the proper conclusion to your article is "Well, you can only claim that because you're using bad examples of promises." Arguing for
async/await
is all good and that, but if you want to make the point that it's clearer than promises, at least use cleanly written code.I really don't understand why you're wrapping everything in a Promise. Assuming that you're various
getIngredient
functions are asynchronous (which judging by yourasync/await
examples they are), you don't need to write this:You can simply do:
Similarly, you don't need to wrap a
Promise.all
within another promise. Instead of this:You can use this:
Which has the advantage of not needing to store the stuff in a variable and return it, as the return will be immediately available in the following
then
statement.And again, if you're going to claim that
async/await
is much cleaner than promises, at the very least don't use code like this:Because that can easily be written like this: