I'm trying to better understand promises and async code in Javascript.
In doing so, I wrote the following, simple async function in the Chrome console:
const myAsync = async() => 10;
As expected, myAsync
returns a promise, but when I call .then()
(i.e. myAsync().then(res => res)
), then console displays Promise{<fulfilled>: 10}
. The promise is clearly fulfilled, but I would expect it to display, simply, the value 10
.
Interestingly, if I modify the body of my call to .then()
to res => alert(res)
, the alert displays what I expect, just 10
.