JavaScript ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ

JavaScript has two secret queues to handle tasks: ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ.

โœจ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ: It’s like a super-fast line where tiny tasks wait their turn. These tasks are usually promises or mutation observers. When a promise resolves or…


This content originally appeared on DEV Community and was authored by Nhan Nguyen

JavaScript has two secret queues to handle tasks: ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ.

Image description

โœจ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ: It's like a super-fast line where tiny tasks wait their turn. These tasks are usually promises or mutation observers. When a promise resolves or a mutation happens, they jump into the Microtask queue.

โœจ ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ: It's like a regular line for more significant tasks. Think setTimeout, callbacks, or fetching data from a server. When these tasks need handling, they join the Macrotask Queue.

JavaScript always finishes what it's doing before checking these queues. But it prioritizes ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ over ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ.

I hope you found it helpful. Thanks for reading. ๐Ÿ™

Let's get connected! You can find me on:


This content originally appeared on DEV Community and was authored by Nhan Nguyen


Print Share Comment Cite Upload Translate Updates
APA

Nhan Nguyen | Sciencx (2024-06-29T05:38:33+00:00) JavaScript ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ. Retrieved from https://www.scien.cx/2024/06/29/javascript-%f0%9d%97%a0%f0%9d%97%b6%f0%9d%97%b0%f0%9d%97%bf%f0%9d%97%bc%f0%9d%98%81%f0%9d%97%ae%f0%9d%98%80%f0%9d%97%b8-%f0%9d%97%a4%f0%9d%98%82%f0%9d%97%b2%f0%9d%98%82%f0%9d%97%b2-and-%f0%9d%97%a0/

MLA
" » JavaScript ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ." Nhan Nguyen | Sciencx - Saturday June 29, 2024, https://www.scien.cx/2024/06/29/javascript-%f0%9d%97%a0%f0%9d%97%b6%f0%9d%97%b0%f0%9d%97%bf%f0%9d%97%bc%f0%9d%98%81%f0%9d%97%ae%f0%9d%98%80%f0%9d%97%b8-%f0%9d%97%a4%f0%9d%98%82%f0%9d%97%b2%f0%9d%98%82%f0%9d%97%b2-and-%f0%9d%97%a0/
HARVARD
Nhan Nguyen | Sciencx Saturday June 29, 2024 » JavaScript ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ., viewed ,<https://www.scien.cx/2024/06/29/javascript-%f0%9d%97%a0%f0%9d%97%b6%f0%9d%97%b0%f0%9d%97%bf%f0%9d%97%bc%f0%9d%98%81%f0%9d%97%ae%f0%9d%98%80%f0%9d%97%b8-%f0%9d%97%a4%f0%9d%98%82%f0%9d%97%b2%f0%9d%98%82%f0%9d%97%b2-and-%f0%9d%97%a0/>
VANCOUVER
Nhan Nguyen | Sciencx - » JavaScript ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/06/29/javascript-%f0%9d%97%a0%f0%9d%97%b6%f0%9d%97%b0%f0%9d%97%bf%f0%9d%97%bc%f0%9d%98%81%f0%9d%97%ae%f0%9d%98%80%f0%9d%97%b8-%f0%9d%97%a4%f0%9d%98%82%f0%9d%97%b2%f0%9d%98%82%f0%9d%97%b2-and-%f0%9d%97%a0/
CHICAGO
" » JavaScript ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ." Nhan Nguyen | Sciencx - Accessed . https://www.scien.cx/2024/06/29/javascript-%f0%9d%97%a0%f0%9d%97%b6%f0%9d%97%b0%f0%9d%97%bf%f0%9d%97%bc%f0%9d%98%81%f0%9d%97%ae%f0%9d%98%80%f0%9d%97%b8-%f0%9d%97%a4%f0%9d%98%82%f0%9d%97%b2%f0%9d%98%82%f0%9d%97%b2-and-%f0%9d%97%a0/
IEEE
" » JavaScript ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ." Nhan Nguyen | Sciencx [Online]. Available: https://www.scien.cx/2024/06/29/javascript-%f0%9d%97%a0%f0%9d%97%b6%f0%9d%97%b0%f0%9d%97%bf%f0%9d%97%bc%f0%9d%98%81%f0%9d%97%ae%f0%9d%98%80%f0%9d%97%b8-%f0%9d%97%a4%f0%9d%98%82%f0%9d%97%b2%f0%9d%98%82%f0%9d%97%b2-and-%f0%9d%97%a0/. [Accessed: ]
rf:citation
» JavaScript ๐— ๐—ถ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ and ๐— ๐—ฎ๐—ฐ๐—ฟ๐—ผ๐˜๐—ฎ๐˜€๐—ธ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ | Nhan Nguyen | Sciencx | https://www.scien.cx/2024/06/29/javascript-%f0%9d%97%a0%f0%9d%97%b6%f0%9d%97%b0%f0%9d%97%bf%f0%9d%97%bc%f0%9d%98%81%f0%9d%97%ae%f0%9d%98%80%f0%9d%97%b8-%f0%9d%97%a4%f0%9d%98%82%f0%9d%97%b2%f0%9d%98%82%f0%9d%97%b2-and-%f0%9d%97%a0/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.