Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript the event loop

* JavaScript is single threaded. so it needs event loop to run asynchronous (Multi Thread) code.
* JavaScript first runs synchronous code, then it queue asynchronous code to call later.
* Asynchronous code is called/executed by event loop.
* System/Browser takes synchronous code and put them as tasks. then these tasks are put them into queue.
* The Event Loop has one simple job — to monitor the is there any task to handle.
* System/Browser push the task to call stack.
* Then the event loop will check the call stack and execute the task.
* Then it waits for the next task to be pushed to the call stack.
Source by newdevpoint.in #
 
PREVIOUS NEXT
Tagged: #javascript #event #loop
ADD COMMENT
Topic
Name
1+7 =