JavaScript Async Flow & Promises
JavaScript is single-threaded, meaning only one thing executes at a time on the call stack. When we call an async function like fetch(), the function itself runs briefly on the call stack, immediately returning a pending Promise, so the synchronous code continues without waiting. The actual async work (e.g., network request, timer) happens outside the JS thread in the browser or Node environment.
Once the async task completes, the engine marks the Promise as fulfilled or rejected. Any .then() or .catch() callbacks attached to the promise are pushed into the microtask queue, not executed immediately. The event loop continuously checks: when the call stack is empty, it drains the microtask queue, moving each callback back onto the call stack for execution.
In short, Promises + event loop + microtasks allow JS to handle async operations without blocking the main thread, ensuring smooth execution. Immediate promises like Promise.resolve(10) simulate this behavior instantly, while real-world async tasks like fetch() take time but follow the same flow.
JavaScript is single-threaded, meaning only one thing executes at a time on the call stack. When we call an async function like fetch(), the function itself runs briefly on the call stack, immediately returning a pending Promise, so the synchronous code continues without waiting. The actual async work (e.g., network request, timer) happens outside the JS thread in the browser or Node environment.
Once the async task completes, the engine marks the Promise as fulfilled or rejected. Any .then() or .catch() callbacks attached to the promise are pushed into the microtask queue, not executed immediately. The event loop continuously checks: when the call stack is empty, it drains the microtask queue, moving each callback back onto the call stack for execution.
In short, Promises + event loop + microtasks allow JS to handle async operations without blocking the main thread, ensuring smooth execution. Immediate promises like Promise.resolve(10) simulate this behavior instantly, while real-world async tasks like fetch() take time but follow the same flow.
β€3
I came across a post and its comments that really made me think.... [The post] and this tech nerd post too [the post] .......
For a long time, Iβve been hesitating to make this channel public.
But now I understand something simple:
"If you wait until you feel confident, youβll never start anything."
Letβs grow togetherπ . If u are senior kindly request to guide me and review my work through the progress too.
https://t.me/code4Lifee
For a long time, Iβve been hesitating to make this channel public.
But now I understand something simple:
"If you wait until you feel confident, youβll never start anything."
Letβs grow togetherπ . If u are senior kindly request to guide me and review my work through the progress too.
https://t.me/code4Lifee
Telegram
Learning Log
Documenting my learning journey.
A2SVian.
Sharing my Projects
A2SVian.
Sharing my Projects
Do you know this? π¦
The dinosaur in the Chrome Dino, the little game that appears when you're offline, is meant to say That u are in the dinosaur era..... π
and now I'm in a situation with poor connectionβ¦ so I'm playing it π
BTW, you can also play it even when you're online.
Just type this in your browser: chrome://dino. π
The dinosaur in the Chrome Dino, the little game that appears when you're offline, is meant to say That u are in the dinosaur era..... π
and now I'm in a situation with poor connectionβ¦ so I'm playing it π
BTW, you can also play it even when you're online.
Just type this in your browser: chrome://dino. π
Forwarded from JavaScript
In CSS is DOOMed, Niels Leenheer shows off how he implemented a version of 1993's Doom using purely CSS rendering (with the game logic in JavaScript). Play it for yourself or check out the code.
JavaScript
In CSS is DOOMed, Niels Leenheer shows off how he implemented a version of 1993's Doom using purely CSS rendering (with the game logic in JavaScript). Play it for yourself or check out the code.
Do u think css is just for styling?
All walls, enemies, gunfire, and effects are built using CSS properties.
π old Doom used JS + Canvas/WebGL.
π this version uses JS + CSS as the drawer, fully playable! Use arrows of Your pc to play it if u like OG.
All walls, enemies, gunfire, and effects are built using CSS properties.
π old Doom used JS + Canvas/WebGL.
π this version uses JS + CSS as the drawer, fully playable! Use arrows of Your pc to play it if u like OG.
π2
I built a very little game tooπ. Open it in Ur browser. If u score more than $20, drop Ur account in the comments.
π1
Want to understand long YouTube videos quickly or got no time to watch?
convert them into transcripts , process it with ai as u want and read it .
tool : link
convert them into transcripts , process it with ai as u want and read it .
tool : link
youtubetotranscript.org
YouTube to Transcript | Free Video to Text Converter
Convert YouTube videos to accurate text transcripts. Free tool with multiple formats and AI analysis.
β€3
ai-models-guide-2026 (1).pdf
540.7 KB
got confused with different ai models dropped every week ? know about categories of the current models , compare them through benchmarks and stay consistently updated.
N.B: categories also cant be constant all time coz each ai models is becoming multimodal
N.B: categories also cant be constant all time coz each ai models is becoming multimodal
β€1