4 ms·
I think this is technically incorrect. It's perfectly valid to await on a literal: > async function test() { let a = "yep"; await a; console.
by claytongulick 5y ago
I think this is technically incorrect.
It's perfectly valid to await on a literal:
> async function test() {
let a = "yep";
await a;
console.log(a);
}
> test()
> yep
- Blahah 5y agowhen 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.