JavaScript › Event Loop & Concurrency
Is JavaScript single-threaded, and what does that mean in practice?
BeginnerAnswer
Yes, JavaScript runs on a single main thread, executing one operation at a time. It achieves the appearance of doing multiple things at once through asynchronous callbacks, Promises, and the event loop — not through true parallel execution on that thread.
console.log('1');
setTimeout(() => console.log('2'), 0);
console.log('3');
// logs: 1, 3, 2Real-world example Understanding why a long synchronous loop freezes the entire page, including scrolling and clicks.