Back to questions
JuniorTheoryCommon
What does the program print (lines separated by spaces)?
async function double(n) {
return n * 2;
}
const x = double(5);
x.then((v) => console.log(v));
console.log(x === 10);false 10
- Expecting
true 10: anasyncfunction always returns a promise, soxis a promise, not10, andx === 10isfalse. - Expecting
10first: thethencallback waits in the microtask queue until the current code, including the last line, has finished.
- How do you get the value
10out ofdouble(5)inside anotherasyncfunction? - What do
typeof xandx instanceof Promisegive for thisx?