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, 2Hiểu rõ cơ chế bất đồng bộ của JavaScript qua mô phỏng tương tác từng bước: xem Call Stack thực thi, Microtask Queue (Promises) và Macrotask/Callback Queue (setTimeout).
| 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) |
Điền các giá trị cần thiết, dán văn bản hoặc tải lên tệp bạn muốn xử lý.
Hầu hết các công cụ cập nhật theo thời gian thực khi bạn nhập liệu; một số công cụ sử dụng một nút hành động duy nhất.
Sao chép, tải xuống hoặc chia sẻ kết quả được tạo — bạn luôn có toàn quyền kiểm soát dữ liệu của mình.
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.
Tạo mã định danh duy nhất toàn cầu UUID v4 có độ ngẫu nhiên mật mã cao hàng loạt.
Định dạng, làm đẹp, kiểm tra cú pháp và nén gọn chuỗi dữ liệu JSON, YAML và XML tức thì.
Tạo mã QR tùy biến cho URL, văn bản, mật khẩu WiFi, danh thiếp vCard và quét mã QR.
Chuyển đổi văn bản hoặc tệp sang chuỗi mã Base64 và giải mã ngược lại tức thì.
Mã hóa hoặc giải mã ký tự đặc biệt trong URL theo chuẩn percent-encoding (RFC 3986).
Chuyển đổi Epoch Unix Timestamp sang ngày giờ thực tế và ngược lại.
Mã hóa và giải mã các ký tự đặc biệt HTML thành thực thể an toàn.
Thử nghiệm và gỡ lỗi biểu thức Regex với hiển thị so khớp thời gian thực.
Giải mã phần Header, Payload và kiểm tra hạn sử dụng của JSON Web Token.
Tạo, giải thích và xem trước lịch chạy của biểu thức Cron biểu diễn thời gian.