Loading workspace environment...
Get started with Node.js syntax, structure, and writing your first program.
// Node.js Event Loop & Async Architecture
async function simulateAsyncJob(id, delay) {
return new Promise((resolve) => {
setTimeout(() => {
resolve(`Job ${id} completed after ${delay}ms`);
}, delay);
});
}
async function runBatch() {
console.log("Starting async batch processing...");
const results = await Promise.all([
simulateAsyncJob("A", 100),
simulateAsyncJob("B", 200),
simulateAsyncJob("C", 50)
]);
results.forEach(r => console.log(" ->", r));
}
runBatch();