Câu 1
Trung bình
Một đáp án
Đoạn code sau in ra theo thứ tự nào?
console.log('1');
setTimeout(() => console.log('2'), 0);
Promise.resolve().then(() => console.log('3'));
console.log('4');
Xem đáp án và giải thích
Thứ tự: code đồng bộ (1, 4) → microtask queue (Promise: 3) → macrotask (setTimeout: 2). Đây là câu "trick" quen thuộc về event loop.