Top Tweets for #settimeout
@chinmay_sawant_ The microtask queue draining before the next macrotask is the part that trips most people. It's not just 'queue of callbacks' - Promise callbacks run after every macrotask, before yielding to render or timers. That's why nested Promises can starve a setTimeout(fn, 0).
Classic trap πͺ€ What prints?
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 0);
}
A) 0 1 2
B) 3 3 3
C) 2 2 2
D) undefined x3
#JavaScript #Frontend
@ose_simeon The answer is '1 4 3 2'. Sync -> Microtask (Promise) -> Macrotask (setTimeout). Great quiz! π
Js quiz time.β±οΈ What's the output order?
console.log(1);
setTimeout(() => console.log(2), 0);
Promise.resolve().then(() => console.log(3));
console.log(4);
A) 1 2 3 4
B) 1 4 2 3
C) 1 4 3 2
D) 1 3 4 2
#JavaScript #WebDev
Developers, whatβs wrong here? π
And what would be the output?
for (var i = 0; i < 4; i++) {
setTimeout(() => console.log(i), 500);
}
Letβs see who actually knows JavaScript and whoβs just vibe coding π
Donβt run it. Guess first.
Developers, whatβs wrong here? π
And what would be the output?
for (var i = 0; i < 4; i++) {
setTimeout(() => console.log(i), 500);
}
Letβs see who actually knows JavaScript and whoβs just vibe coding π
Donβt run it. Guess first.
While promises and async/await use the Microtask Queue, things like setTimeout() and DOM events generally go through the Task Queue.
That small distinction explains a LOT about how asynchronous JavaScript actually behaves.
The key idea:
Synchronous code finishes β microtasks are processed β a task runs β microtasks are checked again β repeat.
Big milestone for Forge π
Forge now has a native Windows IOCP event loop running on top of Mozilla SpiderMonkey.
Current APIs:
β’ print()
β’ setTimeout()
β’ setInterval()
β’ clearTimeout()
Initial benchmark results (Windows):
β‘ Startup
Forge: 19.67 ms
Bun: 40.30 ms
Node: 45.70 ms
π¦ JSON
Forge: 370.43 ms
Bun: 254.04 ms
Node: 553.52 ms
π Loop
Forge: 83.36 ms
Bun: 74.13 ms
Node: 95.11 ms
Still early, but the foundation is coming together.
Next up:
β’ Arena allocator
β’ Collections
β’ Filesystem
β’ Networking
β’ Native HTTP server
Benchmark details and methodology in the next post π
#cpp #JavaScript #SpiderMonkey #OpenSource #SystemsProgramming

@ash_twtz I learned the difference when a setTimeout kept my CI hanging. Now I know which to use.
Day 73 of #100DaysOfCode
JavaScript:-
-setTimeout()
-console.time()
-console.timeEnd()
#javaScript #buildInPublic #LearningInPublic
Day 72 of #100DaysOfCode
Continuing JavaScript:-
-shuffle array
-date object
-closures
#JavaScript #buildInPublic #webDevelopment
@MdSahil_Islam Last used setTimeout() yesterday for a smooth loading animation in a web demo.
Stale closures get "explained" a hundred times but the moment that actually makes them click is usually a specific bug - for me it was a setTimeout reading old state because the callback was created before the state update landed.
@pingkhushi now you know why Promises run before setTimeout()
Guess the output:
function x() {
for (var i = 1; i <= 3; i++) {
setTimeout(function() { console.log(i); }, i * 1000);
}
}
x();
@Wish13T So basically React is fine.
Itβs JavaScript that I personally need therapy for.
And yes, I learned useEffect before I learned why setTimeout behaves like it has commitment issues.
Quick cheat sheet β
Microtask Queue π
β Promises
β Mutation Observer
Callback Queue (Task Queue) β³
β setTimeout
β setInterval
β DOM APIs
β Event Listeners
Microtasks clear fully first. Every. Single. Time. π₯
Not all callbacks go to the same queue. π‘
Promises β Microtask Queue setTimeout β Callback Queue..Chain too many promises?
Callback Queue starves.
MICROTASK QUEUE ALWAYS WINS. π₯
Knew the difference? Reply π
#JavaScript #EventLoop #JSConcepts #LearnInPublic

Quick cheat sheet β
Microtask Queue π
β Promises
β Mutation Observer
Callback Queue (Task Queue) β³
β setTimeout
β setInterval
β DOM APIs
β Event Listeners
Microtasks clear fully first. Every. Single. Time. π₯
Not all callbacks go to the same queue. π‘
Promises β Microtask Queue setTimeout β Callback Queue..Chain too many promises?
Callback Queue starves.
MICROTASK QUEUE ALWAYS WINS. π₯
Knew the difference? Reply π
#JavaScript #EventLoop #JSConcepts #LearnInPublic

Quick cheat sheet β
Microtask Queue π
β Promises
β Mutation Observer
Callback Queue (Task Queue) β³
β setTimeout
β setInterval
β DOM APIs
β Event Listeners
Microtasks clear fully first. Every. Single. Time. π₯
Not all callbacks go to the same queue. π‘
Promises β Microtask Queue setTimeout β Callback Queue..Chain too many promises?
Callback Queue starves.
MICROTASK QUEUE ALWAYS WINS. π₯

Starvation in simple words :-
Microtask creates another microtask.
That one creates another. The chain never ends.
setTimeout is sitting in Callback Queue. Waiting.
CALLBACK QUEUE DOESN'T GET A SINGLE CHANCE TO RUN.
That's Starvation. And it can silently break your app.
Starvation in simple words :-
Microtask creates another microtask.
That one creates another. The chain never ends.
setTimeout is sitting in Callback Queue. Waiting.
CALLBACK QUEUE DOESN'T GET A SINGLE CHANCE TO RUN.
That's Starvation. And it can silently break your app.
Promises + Mutation Observer β Microtask Queue π
setTimeout + EventListeners β Callback Queue
Microtasks keep creating microtasks?
Callback Queue NEVER runs β that's Starvation. π οΈ
SILENT BUT DEADLY.
Starvation in simple words :-
Microtask creates another microtask.
That one creates another. The chain never ends.
setTimeout is sitting in Callback Queue. Waiting.
CALLBACK QUEUE DOESN'T GET A SINGLE CHANCE TO RUN.
That's Starvation. And it can silently break your app.
Starvation in simple words :-
Microtask creates another microtask.
That one creates another. The chain never ends.
setTimeout is sitting in Callback Queue. Waiting.
CALLBACK QUEUE DOESN'T GET A SINGLE CHANCE TO RUN.
That's Starvation. And it can silently break your app.
Promises + Mutation Observer β Microtask Queue π
setTimeout + EventListeners β Callback Queue
Microtasks keep creating microtasks?
Callback Queue NEVER runs β that's Starvation. π οΈ
SILENT BUT DEADLY. Knew this? Reply π
#JavaScript #EventLoop #JSConcepts #LearnInPublic

Last Seen Hashtags on Sotwe
Most Popular Users

Elon Musk 
@elonmusk
239.7M followers

Barack Obama 
@barackobama
118.6M followers

Cristiano Ronaldo 
@cristiano
114.3M followers

Donald J. Trump 
@realdonaldtrump
111.7M followers

Narendra Modi 
@narendramodi
106.9M followers

Rihanna 
@rihanna
98.6M followers

NASA 
@nasa
92.1M followers

Justin Bieber 
@justinbieber
91.7M followers

KATY PERRY 
@katyperry
89.9M followers

Taylor Swift 
@taylorswift13
83.9M followers

Lady Gaga 
@ladygaga
75.4M followers

Virat Kohli 
@imvkohli
73.3M followers

Kim Kardashian 
@kimkardashian
70.8M followers

YouTube 
@youtube
68.6M followers

Neymar Jr 
@neymarjr
66.3M followers

Bill Gates 
@billgates
65.1M followers

Selena Gomez 
@selenagomez
63M followers

The Ellen Show
@theellenshow
62.1M followers

CNN 
@cnn
61.7M followers

X 
@x
60.6M followers













