Question Bank

Promises and async/await Basics

Difficulty: Easy

Beginner drills on Promise resolution order, async/await semantics, and the microtask queue. Three short JavaScript snippets you can predict line-by-line.

Question Bank
/

Promises and async/await Basics

Promises and async/await Basics

Beginner drills on Promise resolution order, async/await semantics, and the microtask queue. Three short JavaScript snippets you can predict line-by-line.

Question Bank
Easy
JavaScript
3 questions
promises
async-await
fundamentals
quiz

155 views

5

Predict the exact print order. Why does the resolved value print after the synchronous tail?

Examples

Example 1:

Input: console.log('A'); Promise.resolve('B').then(v => console.log(v)); console.log('C')
Output: A, then C, then B
Explanation: The script body runs to completion before the event loop drains the microtask queue. Promise.resolve schedules its then callback as a microtask, even for an already-resolved promise.