sync, timeout, promise, sync
Synchronous logs run first, then the promise microtask, then the timeout macrotask.
log(1); setTimeout(2); Promise.then(3); log(4) -> 1, 4, 3, 2Pelajari cara kerja asinkron JavaScript: jalankan contoh kode dengan setTimeout, Promise, async/await, dan lihat bagaimana event loop memproses antrean tugas secara visual.
| Step 1 | console.log('1') | Sync (console.log) |
|---|---|---|
| Step 2 | console.log('4') | Sync (console.log) |
| Step 3 | Promise.resolve().then(() => log('3')) | Microtask (Promise.then) |
| Step 4 | setTimeout(() => log('2'), 0) | Macrotask (setTimeout) |
Isi nilai yang diperlukan, tempel teks Anda, atau unggah file yang ingin diproses.
Sebagian besar alat diperbarui secara langsung saat Anda mengetik; beberapa menggunakan satu tombol tindakan.
Salin, unduh, atau bagikan hasil yang dihasilkan — Anda selalu memiliki kendali penuh atas data Anda.
Build a small script out of synchronous code, microtasks, and macrotasks to see the exact order the JavaScript event loop would run it in.
A `setTimeout(fn, 0)` never runs before a `Promise.resolve().then(fn)`, even with a 0ms delay — every microtask always drains before the next macrotask starts. This surprises most people the first time they see it.
Synchronous logs run first, then the promise microtask, then the timeout macrotask.
log(1); setTimeout(2); Promise.then(3); log(4) -> 1, 4, 3, 2The steps you add are labels for a local ordering model; the tool does not execute arbitrary JavaScript code.
Because microtasks always fully drain before the event loop picks up the next macrotask, regardless of the macrotask's delay — a 0ms timeout is not "immediate", it's just the shortest possible macrotask delay.
Not directly as its own step type, but async/await is built on promises under the hood — an `await` suspends and resumes as a microtask, the same as a `.then()` callback would.
Yes — the relative ordering of "microtasks fully drain between macrotasks" is part of the HTML/ECMAScript specification, not an implementation detail, so every spec-compliant JavaScript engine follows it.
The simulator sorts macrotasks by delay and keeps source order for ties, matching the stable ordering used in the model.
Hasilkan UUID v4 (Universally Unique Identifier) acak berkekuatan kriptografis secara massal.
Format, rapikan, validasi sintaks, atau kompres teks JSON, YAML, dan XML secara instan.
Buat kode QR kustom untuk URL, teks, WiFi, atau kontak vCard, dan pindai kode QR.
Konversi teks atau tệp ke format string Base64 dan decode kembali secara instan.
Enkripsi atau dekripsi teks dan URL ke format persen (percent-encoding) standar RFC 3986.
Konversi waktu epoch Unix (detik/milidetik) ke tanggal manusia dan ISO 8601.
Encode dan decode karakter khusus HTML dan entitas numerik.
Uji dan debug pola regex JavaScript secara langsung dengan penyorotan.
Dekode dan periksa header dan payload JSON Web Token secara aman.
Buat, analisis, dan jelaskan jadwal cron expression secara visual.