3 ms·
when you use `await a`, a is wrapped in a promise. Try returning await a - you get a promise and not the literal. In your example you don't use the promise, and
by Blahah 5y ago
when you use `await a`, a is wrapped in a promise. Try returning await a - you get a promise and not the literal. In your example you don't use the promise, and a is a literal.
> async function test() {
let a = "yep";
return await a;
}
> let b = test()
> console.log(b)
> Promise {
'yep',
[Symbol(async_id_symbol)]: 1215,
[Symbol(trigger_async_id_symbol)]: 5,
[Symbol(destroyed)]: { destroyed: false }
}
The promise you create with `await a` resolves immediately (equivalent to Promise.resolve(a)), but it's still a promise.