Moment For Technology

Eventloop, macro task, micro task

Posted on Aug. 6, 2022, 12:02 p.m. by Thomas Schmidt
Category: The front end Tag: javascript
  • Js is a non-blocking single thread
  • Execution stack: All synchronization tasks are executed on the main thread, and when executed, tasks are successively removed from the task queue to be executed. This process is called an eventloop
  • Macro and micro tasks: Promises(native Promises implemented by browsers), MutationObserver, Process. nextTick, Macro task Note that script, which is the synchronized code that starts out on the main execution stack, is also essentially a MacroTask, which is the first task to execute
  • Execution stack, heap, task queue Execution stack: first in, last out, store Pointers to basic data types and reference data. Heap: Store reference data types. Task queue: store asynchronous tasks, first in, first out
  • New Promise(FN) fn is synchronizing process.nexttick promise. thensetTimeoutsetImmediate SetImmediate When there are multiple setImmediate loops through the execution
Search
About
mo4tech.com (Moment For Technology) is a global community with thousands techies from across the global hang out!Passionate technologists, be it gadget freaks, tech enthusiasts, coders, technopreneurs, or CIOs, you would find them all here.